Source code of Windows XP (NT5)
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.

248 lines
7.6 KiB

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