Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

282 lines
9.1 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1998.
  5. //
  6. // File: pkgdtl.cpp
  7. //
  8. // Contents: package details property page (normally hidden)
  9. //
  10. // Classes: CPackageDetails
  11. //
  12. // History: 03-14-1998 stevebl Commented
  13. //
  14. //---------------------------------------------------------------------------
  15. #include "precomp.hxx"
  16. #include "fcntl.h"
  17. #include "io.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CPackageDetails property page
  25. IMPLEMENT_DYNCREATE(CPackageDetails, CPropertyPage)
  26. CPackageDetails::CPackageDetails() : CPropertyPage(CPackageDetails::IDD)
  27. {
  28. //{{AFX_DATA_INIT(CPackageDetails)
  29. // NOTE: the ClassWizard will add member initialization here
  30. //}}AFX_DATA_INIT
  31. m_hConsoleHandle = NULL;
  32. }
  33. CPackageDetails::~CPackageDetails()
  34. {
  35. *m_ppThis = NULL;
  36. }
  37. void CPackageDetails::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CPropertyPage::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CPackageDetails)
  41. DDX_Control(pDX, IDC_LIST1, m_cList);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CPackageDetails, CPropertyPage)
  45. //{{AFX_MSG_MAP(CPackageDetails)
  46. ON_WM_DESTROY()
  47. ON_WM_CONTEXTMENU()
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CPackageDetails message handlers
  52. // removes tabs and \n characters
  53. void Convert(WCHAR * wsz, CString &sz)
  54. {
  55. sz="";
  56. int iIn=0;
  57. int iOut=0;
  58. WCHAR ch;
  59. while (ch = wsz[iIn++])
  60. {
  61. switch (ch)
  62. {
  63. case L'\t':
  64. iOut++;
  65. sz += ' ';
  66. while (iOut % 4)
  67. {
  68. iOut++;
  69. sz += ' ';
  70. }
  71. break;
  72. case L'\n':
  73. break;
  74. default:
  75. iOut++;
  76. sz += ch;
  77. break;
  78. }
  79. }
  80. }
  81. void CPackageDetails::DumpClassDetail(FILE * stream, CLASSDETAIL * pClass)
  82. {
  83. WCHAR wsz[256];
  84. StringFromGUID2(pClass->Clsid, wsz, 256);
  85. fwprintf(stream, L"\t\tClsid = %s\n",wsz);
  86. StringFromGUID2(pClass->TreatAs, wsz, 256);
  87. fwprintf(stream, L"\t\tTreatAs = %s\n",wsz);
  88. fwprintf(stream, L"\t\tdwComClassContext = %u\n", pClass->dwComClassContext);
  89. fwprintf(stream, L"\t\tcProgId = %u\n",pClass->cProgId);
  90. int i;
  91. for (i = 0; i < pClass->cProgId; i++)
  92. {
  93. fwprintf(stream, L"\t\tprgProgId[%u] = %s\n",i, pClass->prgProgId[i]);
  94. }
  95. }
  96. void CPackageDetails::DumpDetails(FILE * stream)
  97. {
  98. PACKAGEDETAIL * pDetails = m_pData->m_pDetails;
  99. WCHAR wsz[256];
  100. fwprintf(stream, L"pszPackageName = %s\n", pDetails->pszPackageName);
  101. fwprintf(stream, L"pszPublisher = %s\n", pDetails->pszPublisher);
  102. fwprintf(stream, L"cSources = %u\n",pDetails->cSources);
  103. int i;
  104. for (i = 0; i < pDetails->cSources; i++)
  105. {
  106. fwprintf(stream, L"pszSourceList[%u] = %s\n",i, pDetails->pszSourceList[i]);
  107. }
  108. fwprintf(stream, L"cCategories = %u\n",pDetails->cCategories);
  109. for (i = 0; i < pDetails->cCategories; i++)
  110. {
  111. StringFromGUID2(pDetails->rpCategory[i], wsz, 256);
  112. fwprintf(stream, L"rpCategory[%u]\n", i);
  113. }
  114. fwprintf(stream,L"pActInfo = \n{\n");
  115. ACTIVATIONINFO * pActInfo = pDetails->pActInfo;
  116. fwprintf(stream,L"\tcClasses = %u\n",pActInfo->cClasses);
  117. for (i = 0; i < pActInfo->cClasses; i++)
  118. {
  119. fwprintf(stream, L"\tpClasses[%u] = \n\t{\n",i);
  120. DumpClassDetail(stream, &pActInfo->pClasses[i]);
  121. fwprintf(stream, L"\t}\n");
  122. }
  123. fwprintf(stream,L"\tcShellFileExt = %u\n",pActInfo->cShellFileExt);
  124. for (i = 0; i < pActInfo->cShellFileExt; i++)
  125. {
  126. fwprintf(stream, L"\tprgShellFileExt[%u] = %s\n", i, pActInfo->prgShellFileExt[i]);
  127. fwprintf(stream, L"\tprgPriority[%u] = %u\n", i, pActInfo->prgPriority[i]);
  128. }
  129. fwprintf(stream, L"\tcInterfaces = %u\n", pActInfo->cInterfaces);
  130. for (i = 0; i < pActInfo->cInterfaces; i++)
  131. {
  132. StringFromGUID2(pActInfo->prgInterfaceId[i], wsz, 256);
  133. fwprintf(stream, L"\tprgInterfaceId[%u] = %s\n", i, wsz);
  134. }
  135. fwprintf(stream, L"\tcTypeLib = %u\n", pActInfo->cTypeLib);
  136. for (i = 0; i < pActInfo->cTypeLib; i++)
  137. {
  138. StringFromGUID2(pActInfo->prgTlbId[i], wsz, 256);
  139. fwprintf(stream, L"\tprgTlbId[%u] = %s\n", i, wsz);
  140. }
  141. fwprintf(stream,L"}\npPlatformInfo = \n{\n");
  142. PLATFORMINFO * pPlatformInfo = pDetails->pPlatformInfo;
  143. fwprintf(stream, L"\tcPlatforms = %u\n",pPlatformInfo->cPlatforms);
  144. for (i = 0; i < pPlatformInfo->cPlatforms; i++)
  145. {
  146. fwprintf(stream, L"\tprgPlatform[%u] = \n\t{\n",i);
  147. fwprintf(stream, L"\t\tdwPlatformId = 0x%04X\n", pPlatformInfo->prgPlatform[i].dwPlatformId);
  148. fwprintf(stream, L"\t\tdwVersionHi = %u\n", pPlatformInfo->prgPlatform[i].dwVersionHi);
  149. fwprintf(stream, L"\t\tdwVersionLo = %u\n", pPlatformInfo->prgPlatform[i].dwVersionLo);
  150. fwprintf(stream, L"\t\tdwProcessorArch = 0x%04X\n", pPlatformInfo->prgPlatform[i].dwProcessorArch);
  151. fwprintf(stream, L"\t}\n");
  152. }
  153. fwprintf(stream, L"\tcLoacles = %u\n", pPlatformInfo->cLocales);
  154. for (i = 0; i < pPlatformInfo->cLocales; i++)
  155. {
  156. fwprintf(stream, L"\tprgLocale[%u] = 0x%04X\n", i, pPlatformInfo->prgLocale[i]);
  157. }
  158. fwprintf(stream,L"}\npInstallInfo = \n{\n");
  159. INSTALLINFO * pInstallInfo = pDetails->pInstallInfo;
  160. fwprintf(stream, L"\tdwActFlags = 0x%04X\n", pInstallInfo->dwActFlags);
  161. fwprintf(stream, L"\tPathType = %u\n", pInstallInfo->PathType);
  162. fwprintf(stream, L"\tpszScriptPath = %s\n", pInstallInfo->pszScriptPath);
  163. fwprintf(stream, L"\tpszSetupCommand = %s\n",pInstallInfo->pszSetupCommand);
  164. fwprintf(stream, L"\tpszUrl = %s\n",pInstallInfo->pszUrl);
  165. fwprintf(stream, L"\tUsn = %I64u\n",pInstallInfo->Usn);
  166. fwprintf(stream, L"\tInstallUiLevel = %u\n", pInstallInfo->InstallUiLevel);
  167. wsz[0] = 0;
  168. if (pInstallInfo->pClsid)
  169. {
  170. StringFromGUID2(*pInstallInfo->pClsid, wsz, 256);
  171. }
  172. fwprintf(stream, L"\tpClsid = %s\n", wsz);
  173. StringFromGUID2(pInstallInfo->ProductCode, wsz, 256);
  174. fwprintf(stream, L"\tProductCode = %s\n", wsz);
  175. StringFromGUID2(pInstallInfo->Mvipc, wsz, 256);
  176. fwprintf(stream, L"\tMvipc = %s\n", wsz);
  177. fwprintf(stream, L"\tdwVersionHi = %u\n", pInstallInfo->dwVersionHi);
  178. fwprintf(stream, L"\tdwVersionLo = %u\n", pInstallInfo->dwVersionLo);
  179. fwprintf(stream, L"\tdwRevision = %u\n", pInstallInfo->dwRevision);
  180. fwprintf(stream, L"\tcUpgrades = %u\n", pInstallInfo->cUpgrades);
  181. if (pInstallInfo->cUpgrades > 0)
  182. {
  183. fwprintf(stream, L"\tprgUpgradeInfoList[%u] = \n\t{\n", i);
  184. for (i = 0; i < pInstallInfo->cUpgrades; i++)
  185. {
  186. fwprintf(stream, L"\t\tszClassStore = %s\n", pInstallInfo->prgUpgradeInfoList[i].szClassStore);
  187. StringFromGUID2(pInstallInfo->prgUpgradeInfoList[i].PackageGuid, wsz, 256);
  188. fwprintf(stream, L"\t\tPackageGuid = %s\n", wsz);
  189. fwprintf(stream, L"\t\tFlag = %u\n", pInstallInfo->prgUpgradeInfoList[i].Flag);
  190. }
  191. fwprintf(stream, L"\t}\n");
  192. }
  193. fwprintf(stream, L"\tcScriptLen = %u\n", pInstallInfo->cScriptLen);
  194. fwprintf(stream,L"}\n");
  195. }
  196. BOOL CPackageDetails::OnInitDialog()
  197. {
  198. CPropertyPage::OnInitDialog();
  199. RefreshData();
  200. return TRUE; // return TRUE unless you set the focus to a control
  201. // EXCEPTION: OCX Property Pages should return FALSE
  202. }
  203. LRESULT CPackageDetails::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  204. {
  205. switch (message)
  206. {
  207. case WM_USER_REFRESH:
  208. RefreshData();
  209. return 0;
  210. case WM_USER_CLOSE:
  211. return GetOwner()->SendMessage(WM_CLOSE);
  212. default:
  213. return CPropertyPage::WindowProc(message, wParam, lParam);
  214. }
  215. }
  216. void CPackageDetails::RefreshData(void)
  217. {
  218. m_cList.ResetContent();
  219. // Dump the m_pData->m_pDetails structure here
  220. FILE * stream = tmpfile();
  221. if (stream)
  222. {
  223. _setmode(_fileno(stream), _O_TEXT);
  224. DumpDetails(stream);
  225. rewind(stream);
  226. WCHAR wsz[256];
  227. CString szTemp;
  228. int cWidth = 0;
  229. while (fgetws(wsz, 256, stream))
  230. {
  231. Convert(wsz, szTemp);
  232. CDC * pDC = m_cList.GetDC();
  233. CSize csExtent = pDC->GetTextExtent(szTemp);
  234. pDC->LPtoDP(&csExtent);
  235. m_cList.ReleaseDC(pDC);
  236. if (cWidth < csExtent.cx)
  237. {
  238. cWidth = csExtent.cx;
  239. }
  240. m_cList.AddString(szTemp);
  241. }
  242. m_cList.SetHorizontalExtent(cWidth);
  243. fclose(stream);
  244. }
  245. }
  246. void CPackageDetails::OnContextMenu(CWnd* pWnd, CPoint point)
  247. {
  248. StandardContextMenu(pWnd->m_hWnd, IDD_PACKAGE_DETAILS);
  249. }