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.

745 lines
24 KiB

  1. #include "item.h"
  2. #include "parseinf.h"
  3. #include <mstask.h>
  4. #include <iehelpid.h>
  5. #include "parseinf.h"
  6. #include <mluisupp.h>
  7. #ifdef AUTO_UPDATE
  8. #define NUM_PAGES 4
  9. #else
  10. #define NUM_PAGES 3
  11. #endif
  12. #define DEFAULT_LANG_CODEPAGE_PAIR 0x040904B0
  13. #define MAX_QUERYPREFIX_LEN 512
  14. #define MAX_QUERYSTRING_LEN 1024
  15. // defined in utils.cpp
  16. extern LPCTSTR g_lpszUpdateInfo;
  17. extern LPCTSTR g_lpszCookieValue;
  18. extern LPCTSTR g_lpszSavedValue;
  19. ///////////////////////////////////////////////////////////////////////////////
  20. // functions that deal with web check
  21. // define a macro to make life easier
  22. #define QUIT_IF_FAIL if (FAILED(hr)) goto Exit
  23. void DestroyDialogIcon(HWND hDlg)
  24. {
  25. HICON hIcon = (HICON)SendDlgItemMessage(
  26. hDlg, IDC_STATIC_ICON,
  27. STM_GETICON, 0, 0);
  28. if (hIcon != NULL)
  29. DestroyIcon(hIcon);
  30. }
  31. ///////////////////////////////////////////////////////////////////////////////
  32. // functions that deal with property page 1
  33. void InitPropPage1(HWND hDlg, LPARAM lParam)
  34. {
  35. BOOL bHasActiveX;
  36. BOOL bHasJava;
  37. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  38. LPCONTROLPIDL pcpidl = (LPCONTROLPIDL)((LPPROPSHEETPAGE)lParam)->lParam;
  39. if (pcpidl)
  40. {
  41. // draw control icon
  42. {
  43. HICON hIcon = ExtractIcon(g_hInst, GetStringInfo(pcpidl, SI_LOCATION), 0);
  44. if (hIcon == NULL)
  45. hIcon = GetDefaultOCIcon( pcpidl );
  46. Assert(hIcon != NULL);
  47. SendDlgItemMessage(hDlg, IDC_STATIC_ICON, STM_SETICON, (WPARAM)hIcon, 0);
  48. }
  49. SetDlgItemText(hDlg, IDC_STATIC_CONTROL, GetStringInfo(pcpidl, SI_CONTROL));
  50. SetDlgItemText(hDlg, IDC_STATIC_CREATION, GetStringInfo(pcpidl, SI_CREATION));
  51. SetDlgItemText(hDlg, IDC_STATIC_LASTACCESS, GetStringInfo(pcpidl, SI_LASTACCESS));
  52. SetDlgItemText(hDlg, IDC_STATIC_CLSID, GetStringInfo(pcpidl, SI_CLSID));
  53. SetDlgItemText(hDlg, IDC_STATIC_CODEBASE, GetStringInfo(pcpidl, SI_CODEBASE));
  54. TCHAR szBuf[MESSAGE_MAXSIZE];
  55. GetContentBools( pcpidl, &bHasActiveX, &bHasJava );
  56. if ( bHasJava )
  57. {
  58. if ( bHasActiveX )
  59. MLLoadString(IDS_PROPERTY_TYPE_MIXED, szBuf, MESSAGE_MAXSIZE);
  60. else
  61. MLLoadString(IDS_PROPERTY_TYPE_JAVA, szBuf, MESSAGE_MAXSIZE);
  62. }
  63. else
  64. MLLoadString(IDS_PROPERTY_TYPE_ACTX, szBuf, MESSAGE_MAXSIZE);
  65. SetDlgItemText(hDlg, IDC_STATIC_TYPE, szBuf);
  66. GetStatus(pcpidl, szBuf, MESSAGE_MAXSIZE);
  67. SetDlgItemText(hDlg, IDC_STATIC_STATUS, szBuf);
  68. DWORD dwSizeSaved = GetSizeSaved(pcpidl);
  69. TCHAR szSize[20];
  70. wsprintf(szSize, "%u", dwSizeSaved);
  71. // insert commas to separate groups of digits
  72. int nLen = lstrlen(szSize);
  73. int i = 0, j = (nLen <= 3 ? nLen : (nLen % 3));
  74. TCHAR *pCh = szSize + j;
  75. for (; i < j; i++)
  76. szBuf[i] = szSize[i];
  77. for (; *pCh != '\0'; i++, pCh++)
  78. {
  79. if (((pCh - szSize) % 3 == j) && (i > 0))
  80. szBuf[i++] = ',';
  81. szBuf[i] = *pCh;
  82. }
  83. szBuf[i] = '\0';
  84. TCHAR szBytes[BYTES_MAXSIZE];
  85. MLLoadString(IDS_PROPERTY_BYTES, szBytes, BYTES_MAXSIZE);
  86. lstrcat(szBuf, TEXT(" "));
  87. lstrcat(szBuf, szBytes);
  88. lstrcat(szBuf, TEXT(" ("));
  89. GetSizeSaved(pcpidl, szBuf + lstrlen(szBuf));
  90. lstrcat(szBuf, TEXT(")"));
  91. SetDlgItemText(hDlg, IDC_STATIC_TOTALSIZE, szBuf);
  92. }
  93. }
  94. // Dialog proc for page 1
  95. INT_PTR CALLBACK ControlItem_PropPage1Proc(
  96. HWND hDlg,
  97. UINT message,
  98. WPARAM wParam,
  99. LPARAM lParam)
  100. {
  101. LPPROPSHEETPAGE lpPropSheet = (LPPROPSHEETPAGE) GetWindowLongPtr(hDlg, DWLP_USER);
  102. LPCONTROLPIDL pcpidl = lpPropSheet ? (LPCONTROLPIDL)lpPropSheet->lParam : NULL;
  103. const static DWORD aIds[] = {
  104. IDC_STATIC_LABEL_TYPE, IDH_DLOAD_TYPE,
  105. IDC_STATIC_LABEL_CREATION, IDH_DLOAD_CREATED,
  106. IDC_STATIC_LABEL_LASTACCESS, IDH_DLOAD_LASTACC,
  107. IDC_STATIC_LABEL_TOTALSIZE, IDH_DLOAD_TOTALSIZE,
  108. IDC_STATIC_LABEL_CLSID, IDH_DLOAD_ID,
  109. IDC_STATIC_LABEL_STATUS, IDH_DLOAD_STATUS,
  110. IDC_STATIC_LABEL_CODEBASE, IDH_DLOAD_CODEBASE,
  111. IDC_STATIC_TYPE, IDH_DLOAD_TYPE,
  112. IDC_STATIC_CREATION, IDH_DLOAD_CREATED,
  113. IDC_STATIC_LASTACCESS, IDH_DLOAD_LASTACC,
  114. IDC_STATIC_TOTALSIZE, IDH_DLOAD_TOTALSIZE,
  115. IDC_STATIC_CLSID, IDH_DLOAD_ID,
  116. IDC_STATIC_STATUS, IDH_DLOAD_STATUS,
  117. IDC_STATIC_CODEBASE, IDH_DLOAD_CODEBASE,
  118. IDC_STATIC_CONTROL, IDH_DLOAD_OBJNAME,
  119. 0, 0
  120. };
  121. switch(message)
  122. {
  123. case WM_HELP:
  124. SHWinHelpOnDemandWrap((HWND)(((LPHELPINFO)lParam)->hItemHandle), "iexplore.hlp", HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  125. break;
  126. case WM_CONTEXTMENU:
  127. SHWinHelpOnDemandWrap((HWND)wParam, "iexplore.hlp", HELP_CONTEXTMENU, (DWORD_PTR)(LPVOID)aIds);
  128. break;
  129. case WM_INITDIALOG:
  130. InitPropPage1(hDlg, lParam);
  131. break;
  132. case WM_DESTROY:
  133. DestroyDialogIcon(hDlg);
  134. break;
  135. case WM_COMMAND:
  136. // user can't change anything, so we don't care about any messages
  137. break;
  138. default:
  139. return FALSE;
  140. } // end of switch
  141. return TRUE;
  142. }
  143. ///////////////////////////////////////////////////////////////////////////////
  144. // functions that deal with property page 2
  145. int ListCtrl_InsertColumn(
  146. HWND hwnd,
  147. int nCol,
  148. LPCTSTR lpszColumnHeading,
  149. int nFormat,
  150. int nWidth,
  151. int nSubItem)
  152. {
  153. LV_COLUMN column;
  154. column.mask = LVCF_TEXT|LVCF_FMT;
  155. column.pszText = (LPTSTR)lpszColumnHeading;
  156. column.fmt = nFormat;
  157. if (nWidth != -1)
  158. {
  159. column.mask |= LVCF_WIDTH;
  160. column.cx = nWidth;
  161. }
  162. if (nSubItem != -1)
  163. {
  164. column.mask |= LVCF_SUBITEM;
  165. column.iSubItem = nSubItem;
  166. }
  167. return (int)::SendMessage(hwnd, LVM_INSERTCOLUMN, nCol, (LPARAM)&column);
  168. }
  169. BOOL ListCtrl_SetItemText(
  170. HWND hwnd,
  171. int nItem,
  172. int nSubItem,
  173. LPCTSTR lpszItem)
  174. {
  175. LV_ITEM lvi;
  176. lvi.mask = LVIF_TEXT;
  177. lvi.iItem = nItem;
  178. lvi.iSubItem = nSubItem;
  179. lvi.stateMask = 0;
  180. lvi.state = 0;
  181. lvi.pszText = (LPTSTR) lpszItem;
  182. lvi.iImage = 0;
  183. lvi.lParam = 0;
  184. return (BOOL)::SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&lvi);
  185. }
  186. int ListCtrl_InsertItem(
  187. HWND hwnd,
  188. UINT nMask,
  189. int nItem,
  190. LPCTSTR lpszItem,
  191. UINT nState,
  192. UINT nStateMask,
  193. int nImage,
  194. LPARAM lParam)
  195. {
  196. LV_ITEM item;
  197. item.mask = nMask;
  198. item.iItem = nItem;
  199. item.iSubItem = 0;
  200. item.pszText = (LPTSTR)lpszItem;
  201. item.state = nState;
  202. item.stateMask = nStateMask;
  203. item.iImage = nImage;
  204. item.lParam = lParam;
  205. return (int)::SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM)&item);
  206. }
  207. void InitPropPage2(HWND hDlg, LPARAM lParam)
  208. {
  209. int iFileNameWidth = 0;
  210. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  211. LPCONTROLPIDL pcpidl = (LPCONTROLPIDL)((LPPROPSHEETPAGE)lParam)->lParam;
  212. UINT cTotalFiles = GetTotalNumOfFiles(pcpidl);
  213. {
  214. HICON hIcon = ExtractIcon(g_hInst, GetStringInfo(pcpidl, SI_LOCATION), 0);
  215. if (hIcon == NULL)
  216. hIcon = GetDefaultOCIcon( pcpidl );
  217. Assert(hIcon != NULL);
  218. SendDlgItemMessage(hDlg, IDC_STATIC_ICON, STM_SETICON, (WPARAM)hIcon, 0);
  219. }
  220. // insert columns into file list box
  221. RECT rect;
  222. int nWidth;
  223. TCHAR szBuf[MAX_PATH];
  224. HWND hwndCtrl = GetDlgItem(hDlg, IDC_DEPENDENCYLIST);
  225. Assert(::IsWindow(hwndCtrl));
  226. GetClientRect(hwndCtrl, &rect);
  227. nWidth = rect.right - rect.left;
  228. MLLoadString(IDS_LISTTITLE_FILENAME, szBuf, MAX_PATH);
  229. iFileNameWidth = nWidth * 7 / 10;
  230. ListCtrl_InsertColumn(
  231. hwndCtrl,
  232. 0,
  233. szBuf,
  234. LVCFMT_LEFT,
  235. iFileNameWidth, 0);
  236. MLLoadString(IDS_LISTTITLE_FILESIZE, szBuf, MAX_PATH);
  237. ListCtrl_InsertColumn(
  238. hwndCtrl,
  239. 1,
  240. szBuf,
  241. LVCFMT_LEFT,
  242. nWidth * 3 / 10,
  243. 0);
  244. // insert dependent files into list box
  245. int iIndex = -1;
  246. LONG lResult = ERROR_SUCCESS;
  247. DWORD dwFileSize = 0;
  248. BOOL bOCXRemovable = IsModuleRemovable(GetStringInfo(pcpidl, SI_LOCATION));
  249. for (UINT iFile = 0; iFile < cTotalFiles; iFile++)
  250. {
  251. if (!GetDependentFile(pcpidl, iFile, szBuf, &dwFileSize))
  252. {
  253. Assert(FALSE);
  254. break;
  255. }
  256. // put a star after file name if file is not safe for removal
  257. if (!bOCXRemovable)
  258. {
  259. lstrcat(szBuf, TEXT("*"));
  260. }
  261. else if (!IsModuleRemovable(szBuf))
  262. {
  263. // check if it is inf file.
  264. TCHAR szExt[10];
  265. MLLoadString(IDS_EXTENSION_INF, szExt, 10);
  266. int nLen = lstrlen(szBuf);
  267. int nLenExt = lstrlen(szExt);
  268. if ((nLen > nLenExt) &&
  269. (lstrcmpi(szBuf+(nLen-nLenExt), szExt) != 0))
  270. lstrcat(szBuf, TEXT("*"));
  271. }
  272. PathCompactPath(NULL, szBuf, iFileNameWidth);
  273. iIndex = ListCtrl_InsertItem(hwndCtrl, LVIF_TEXT, iFile, szBuf, 0, 0, 0, 0);
  274. if (dwFileSize > 0)
  275. {
  276. TCHAR szBuf2[100];
  277. wsprintf(szBuf2, "%u", dwFileSize);
  278. // insert commas to separate groups of digits
  279. int nLen = lstrlen(szBuf2);
  280. int i = 0, j = (nLen <= 3 ? nLen : (nLen % 3));
  281. TCHAR *pCh = szBuf2 + j;
  282. for (; i < j; i++)
  283. szBuf[i] = szBuf2[i];
  284. for (; *pCh != '\0'; i++, pCh++)
  285. {
  286. if (((pCh - szBuf2) % 3 == j) && (i > 0))
  287. szBuf[i++] = ',';
  288. szBuf[i] = *pCh;
  289. }
  290. szBuf[i] = '\0';
  291. }
  292. else
  293. MLLoadString(IDS_STATUS_DAMAGED, szBuf, MAX_PATH);
  294. ListCtrl_SetItemText(hwndCtrl, iIndex, 1, szBuf);
  295. }
  296. // insert columns into file list box
  297. hwndCtrl = GetDlgItem(hDlg, IDC_PACKAGELIST);
  298. Assert(::IsWindow(hwndCtrl));
  299. GetClientRect(hwndCtrl, &rect);
  300. nWidth = (rect.right - rect.left) / 2;
  301. MLLoadString(IDS_LISTTITLE_PACKAGENAME, szBuf, MAX_PATH);
  302. ListCtrl_InsertColumn(
  303. hwndCtrl,
  304. 0,
  305. szBuf,
  306. LVCFMT_LEFT,
  307. nWidth, 0);
  308. MLLoadString(IDS_LISTTITLE_NAMESPACE, szBuf, MAX_PATH);
  309. ListCtrl_InsertColumn(
  310. hwndCtrl,
  311. 1,
  312. szBuf,
  313. LVCFMT_LEFT,
  314. nWidth, 0);
  315. // insert dependent packages into list box
  316. UINT cTotalPackages = 0;;
  317. if ( pcpidl->ci.dwIsDistUnit )
  318. {
  319. CParseInf parseInf;
  320. if ( SUCCEEDED(parseInf.DoParseDU( GetStringInfo( pcpidl, SI_LOCATION), GetStringInfo( pcpidl,SI_CLSID ))) )
  321. {
  322. CPackageNode *ppn;
  323. for ( ppn = parseInf.GetFirstPackage();
  324. ppn != NULL;
  325. ppn = parseInf.GetNextPackage(), cTotalPackages++ )
  326. {
  327. iIndex = ListCtrl_InsertItem(hwndCtrl, LVIF_TEXT, cTotalPackages, ppn->GetName(), 0, 0, 0, 0);
  328. ListCtrl_SetItemText(hwndCtrl, iIndex, 1, ppn->GetNamespace());
  329. }
  330. }
  331. }
  332. // update description
  333. {
  334. TCHAR szMsg[MESSAGE_MAXSIZE];
  335. TCHAR szBuf[MESSAGE_MAXSIZE];
  336. // BUG: This is not the correct way to make va_list for Alpha
  337. DWORD_PTR adwArgs[3];
  338. adwArgs[0] = cTotalFiles;
  339. adwArgs[1] = cTotalPackages;
  340. adwArgs[2] = (DWORD_PTR) GetStringInfo(pcpidl, SI_CONTROL);
  341. MLLoadString(IDS_MSG_DEPENDENCY, szBuf, MESSAGE_MAXSIZE);
  342. FormatMessage( FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  343. szBuf, 0, 0, szMsg, MESSAGE_MAXSIZE, (va_list*)adwArgs );
  344. SetDlgItemText(hDlg, IDC_STATIC_DESCRIPTION, szMsg);
  345. }
  346. }
  347. // Dialog proc for page 2
  348. INT_PTR CALLBACK ControlItem_PropPage2Proc(
  349. HWND hDlg,
  350. UINT message,
  351. WPARAM wParam,
  352. LPARAM lParam)
  353. {
  354. LPPROPSHEETPAGE lpPropSheet = (LPPROPSHEETPAGE) GetWindowLongPtr(hDlg, DWLP_USER);
  355. LPCONTROLPIDL pcpidl = lpPropSheet ? (LPCONTROLPIDL)lpPropSheet->lParam : NULL;
  356. const static DWORD aIds[] = {
  357. IDC_DEPENDENCYLIST, IDH_DLOAD_FILE_DEP,
  358. IDC_PACKAGELIST, IDH_DLOAD_JAVAPKG_DEP,
  359. 0, 0
  360. };
  361. switch(message)
  362. {
  363. case WM_HELP:
  364. SHWinHelpOnDemandWrap((HWND)(((LPHELPINFO)lParam)->hItemHandle), "iexplore.hlp", HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  365. break;
  366. case WM_CONTEXTMENU:
  367. SHWinHelpOnDemandWrap((HWND)wParam, "iexplore.hlp", HELP_CONTEXTMENU, (DWORD_PTR)(LPVOID)aIds);
  368. break;
  369. case WM_INITDIALOG:
  370. InitPropPage2(hDlg, lParam);
  371. break;
  372. case WM_DESTROY:
  373. DestroyDialogIcon(hDlg);
  374. break;
  375. case WM_COMMAND:
  376. break;
  377. default:
  378. return FALSE;
  379. } // end of switch
  380. return TRUE;
  381. }
  382. #if 0
  383. // Do UI update
  384. BOOL Page3_OnCommand(HWND hDlg, WORD wCmd)
  385. {
  386. HWND hwnd = GetDlgItem(hDlg, IDC_CHECK_NEVERUPDATE);
  387. Assert(hwnd != NULL);
  388. // if top check box is checked, disable the edit box
  389. BOOL bEnable = ((int)::SendMessage(hwnd, BM_GETCHECK, 0, 0) != 1);
  390. hwnd = GetDlgItem(hDlg, IDC_EDIT_UPDATEINTERVAL);
  391. Assert(hwnd != NULL);
  392. EnableWindow(hwnd, bEnable);
  393. // if top check box is not checked and edit box does not
  394. // have the focus and it is empty, put in default interval
  395. if (bEnable && (GetFocus() != hwnd))
  396. {
  397. TCHAR szText[10];
  398. if (GetWindowText(hwnd, szText, 10) == 0)
  399. {
  400. // wsprintf(szText, "%i", g_dwDefaultInterval);
  401. SetWindowText(hwnd, szText);
  402. }
  403. }
  404. return TRUE;
  405. }
  406. #endif
  407. ///////////////////////////////////////////////////////////////////////////////
  408. // functions that deal with property page 4
  409. void InitPropPage4(HWND hDlg, LPARAM lParam)
  410. {
  411. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  412. LPCONTROLPIDL pcpidl = (LPCONTROLPIDL)((LPPROPSHEETPAGE)lParam)->lParam;
  413. LPTSTR lpszFileName = (LPTSTR)GetStringInfo(pcpidl, SI_LOCATION);
  414. TCHAR szBuf[MESSAGE_MAXSIZE];
  415. DWORD dwHandle = 0, dwSizeVer = 0;
  416. LPTSTR lpBuffer = NULL;
  417. UINT uSize = 0;
  418. LPVOID lpVerData = NULL;
  419. UINT uLen = 0;
  420. DWORD dwLangCodePage = 0;
  421. char szQueryPrefix[MAX_QUERYPREFIX_LEN];
  422. char szQueryString[MAX_QUERYSTRING_LEN];
  423. // draw control icon
  424. {
  425. LPCTSTR pszIcon = GetStringInfo(pcpidl, SI_LOCATION);
  426. HICON hIcon = NULL;
  427. if (!pszIcon || !(hIcon = ExtractIcon(g_hInst, pszIcon, 0)))
  428. {
  429. hIcon = GetDefaultOCIcon( pcpidl );
  430. }
  431. Assert(hIcon != NULL);
  432. SendDlgItemMessage(hDlg, IDC_STATIC_ICON, STM_SETICON, (WPARAM)hIcon, 0);
  433. }
  434. // set page header
  435. if (MLLoadString(IDS_VERSION_PAGE_HEADER, szBuf, MESSAGE_MAXSIZE))
  436. {
  437. TCHAR szHeading[MESSAGE_MAXSIZE];
  438. LPCTSTR pszControl = GetStringInfo(pcpidl, SI_CONTROL);
  439. if (pszControl)
  440. {
  441. wsprintf(szHeading, szBuf, pszControl);
  442. SetDlgItemText(hDlg, IDC_STATIC_VER_HEADING, szHeading);
  443. }
  444. }
  445. // set Version field
  446. LPCTSTR pszVersion = GetStringInfo(pcpidl, SI_VERSION);
  447. if (!pszVersion)
  448. return;
  449. SetDlgItemText(hDlg, IDC_STATIC_VER_VERSION, pszVersion);
  450. if (!lpszFileName)
  451. return;
  452. dwSizeVer = GetFileVersionInfoSize(lpszFileName, &dwHandle);
  453. if (dwSizeVer <= 0)
  454. return;
  455. BYTE *pbData = new BYTE[dwSizeVer];
  456. if (pbData == NULL)
  457. return;
  458. if (GetFileVersionInfo(lpszFileName, 0, dwSizeVer, pbData))
  459. {
  460. // Get correct codepage information
  461. if (!VerQueryValue(pbData, "\\VarFileInfo\\Translation", &lpVerData, &uLen))
  462. {
  463. wsprintf(szQueryPrefix, "\\StringFileInfo\\%x\\CompanyName", DEFAULT_LANG_CODEPAGE_PAIR);
  464. }
  465. else
  466. {
  467. char szLangCodePad[9];
  468. char szVBufPad[5], szVBuf[5]; // To fit a DWORD (padded)
  469. ASSERT(lpVerData);
  470. wnsprintf(szVBuf, ARRAYSIZE(szVBuf), "%x", LOWORD(*((DWORD *)lpVerData)));
  471. // Pad the low word to 4 digits
  472. lstrcpyn(szVBufPad, "0000", ARRAYSIZE(szVBufPad));
  473. char *pszTmp = szVBufPad + (4 - lstrlen(szVBuf));
  474. ASSERT(pszTmp > szVBufPad);
  475. lstrcpy(pszTmp, szVBuf);
  476. lstrcpyn(szLangCodePad, szVBufPad, ARRAYSIZE(szLangCodePad));
  477. // Pad the high word to 4 digits
  478. wnsprintf(szVBuf, ARRAYSIZE(szVBuf), "%x", HIWORD(*((DWORD *)lpVerData)));
  479. lstrcpy(szVBufPad, "0000");
  480. pszTmp = szVBufPad + (4 - lstrlen(szVBuf));
  481. ASSERT(pszTmp > szVBufPad);
  482. lstrcpy(pszTmp, szVBuf);
  483. // Concatenate to get a codepage/lang-id string
  484. lstrcatn(szLangCodePad, szVBufPad, ARRAYSIZE(szLangCodePad));
  485. lstrcpy(szQueryPrefix, "\\StringFileInfo\\");
  486. lstrcat(szQueryPrefix, szLangCodePad);
  487. }
  488. // set Company field
  489. wnsprintf(szQueryString, ARRAYSIZE(szQueryString), "%s\\CompanyName", szQueryPrefix);
  490. if (VerQueryValue(pbData, szQueryString, (void **)&lpBuffer, &uSize))
  491. SetDlgItemText(hDlg, IDC_STATIC_VER_COMPANY, lpBuffer);
  492. // set Description field
  493. wnsprintf(szQueryString, ARRAYSIZE(szQueryString), "%s\\FileDescription", szQueryPrefix);
  494. if (VerQueryValue(pbData, szQueryString, (void **)&lpBuffer, &uSize))
  495. SetDlgItemText(hDlg, IDC_STATIC_VER_DESCRIPTION, lpBuffer);
  496. // set CopyRight field
  497. wnsprintf(szQueryString, ARRAYSIZE(szQueryString), "%s\\LegalCopyright", szQueryPrefix);
  498. if (VerQueryValue(pbData, szQueryString, (void **)&lpBuffer, &uSize))
  499. SetDlgItemText(hDlg, IDC_STATIC_VER_COPYRIGHT, lpBuffer);
  500. // set Language field
  501. if (VerQueryValue(pbData, TEXT("\\VarFileInfo\\Translation"), (void **)&lpBuffer, &uSize))
  502. {
  503. LPWORD lpLangId = (LPWORD)lpBuffer;
  504. VerLanguageName(*lpLangId, szBuf, MESSAGE_MAXSIZE);
  505. SetDlgItemText(hDlg, IDC_STATIC_VER_LANGUAGE, szBuf);
  506. }
  507. }
  508. delete [] pbData;
  509. }
  510. // Dialog proc for page 4
  511. INT_PTR CALLBACK ControlItem_PropPage4Proc(
  512. HWND hDlg,
  513. UINT message,
  514. WPARAM wParam,
  515. LPARAM lParam)
  516. {
  517. LPPROPSHEETPAGE lpPropSheet = (LPPROPSHEETPAGE) GetWindowLongPtr(hDlg, DWLP_USER);
  518. LPCONTROLPIDL pcpidl = lpPropSheet ? (LPCONTROLPIDL)lpPropSheet->lParam : NULL;
  519. const static DWORD aIds[] = {
  520. IDC_STATIC_VER_LABEL_VERSION, IDH_DLOAD_VERSION,
  521. IDC_STATIC_VER_LABEL_DESCRIPTION, IDH_DLOAD_DESC,
  522. IDC_STATIC_VER_LABEL_COMPANY, IDH_DLOAD_COMPANY,
  523. IDC_STATIC_VER_LABEL_LANGUAGE, IDH_DLOAD_LANG,
  524. IDC_STATIC_VER_LABEL_COPYRIGHT, IDH_DLOAD_COPYRIGHT,
  525. IDC_STATIC_VER_VERSION, IDH_DLOAD_VERSION,
  526. IDC_STATIC_VER_DESCRIPTION, IDH_DLOAD_DESC,
  527. IDC_STATIC_VER_COMPANY, IDH_DLOAD_COMPANY,
  528. IDC_STATIC_VER_LANGUAGE, IDH_DLOAD_LANG,
  529. IDC_STATIC_VER_COPYRIGHT, IDH_DLOAD_COPYRIGHT,
  530. IDC_STATIC_CONTROL, IDH_DLOAD_OBJNAME,
  531. 0, 0
  532. };
  533. switch(message)
  534. {
  535. case WM_HELP:
  536. SHWinHelpOnDemandWrap((HWND)(((LPHELPINFO)lParam)->hItemHandle), "iexplore.hlp", HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  537. break;
  538. case WM_CONTEXTMENU:
  539. SHWinHelpOnDemandWrap((HWND)wParam, "iexplore.hlp", HELP_CONTEXTMENU, (DWORD_PTR)(LPVOID)aIds);
  540. break;
  541. case WM_INITDIALOG:
  542. InitPropPage4(hDlg, lParam);
  543. break;
  544. case WM_DESTROY:
  545. DestroyDialogIcon(hDlg);
  546. break;
  547. case WM_COMMAND:
  548. // user can't change anything, so we don't care about any messages
  549. break;
  550. default:
  551. return FALSE;
  552. } // end of switch
  553. return TRUE;
  554. }
  555. ///////////////////////////////////////////////////////////////////////////////
  556. // functions that deal with property dialog
  557. HRESULT CreatePropDialog(HWND hwnd, LPCONTROLPIDL pcpidl)
  558. {
  559. #ifdef AUTO_UPDATE
  560. PROPSHEETPAGE psp[NUM_PAGES] = {{0},{0},{0},{0}};
  561. #else
  562. PROPSHEETPAGE psp[NUM_PAGES] = {{0},{0},{0}};
  563. #endif
  564. PROPSHEETHEADER psh = {0};
  565. // initialize propsheet page 1.
  566. psp[0].dwSize = sizeof(PROPSHEETPAGE);
  567. psp[0].dwFlags = 0;
  568. psp[0].hInstance = MLGetHinst();
  569. psp[0].pszTemplate = MAKEINTRESOURCE(IDD_PROP_GENERAL);
  570. psp[0].pszIcon = NULL;
  571. psp[0].pfnDlgProc = ControlItem_PropPage1Proc;
  572. psp[0].pszTitle = NULL;
  573. psp[0].lParam = (LPARAM)pcpidl; // send it the cache entry struct
  574. // initialize propsheet page 2.
  575. psp[1].dwSize = sizeof(PROPSHEETPAGE);
  576. psp[1].dwFlags = 0;
  577. psp[1].hInstance = MLGetHinst();
  578. psp[1].pszTemplate = MAKEINTRESOURCE(IDD_PROP_DEPENDENCY);
  579. psp[1].pszIcon = NULL;
  580. psp[1].pfnDlgProc = ControlItem_PropPage2Proc;
  581. psp[1].pszTitle = NULL;
  582. psp[1].lParam = (LPARAM)pcpidl; // send it the cache entry struct
  583. #ifdef AUTO_UPDATE
  584. // initialize propsheet page 3.
  585. psp[2].dwSize = sizeof(PROPSHEETPAGE);
  586. psp[2].dwFlags = 0;
  587. psp[2].hInstance = MLGetHinst();
  588. psp[2].pszTemplate = MAKEINTRESOURCE(IDD_PROP_UPDATE);
  589. psp[2].pszIcon = NULL;
  590. psp[2].pfnDlgProc = ControlItem_PropPage3Proc;
  591. psp[2].pszTitle = NULL;
  592. psp[2].lParam = (LPARAM)pcpidl; // send it the cache entry struct
  593. #endif
  594. // initialize propsheet page 4.
  595. psp[NUM_PAGES-1].dwSize = sizeof(PROPSHEETPAGE);
  596. psp[NUM_PAGES-1].dwFlags = 0;
  597. psp[NUM_PAGES-1].hInstance = MLGetHinst();
  598. psp[NUM_PAGES-1].pszTemplate = MAKEINTRESOURCE(IDD_PROP_VERSION);
  599. psp[NUM_PAGES-1].pszIcon = NULL;
  600. psp[NUM_PAGES-1].pfnDlgProc = ControlItem_PropPage4Proc;
  601. psp[NUM_PAGES-1].pszTitle = NULL;
  602. psp[NUM_PAGES-1].lParam = (LPARAM)pcpidl; // send it the cache entry struct
  603. // initialize propsheet header.
  604. psh.dwSize = sizeof(PROPSHEETHEADER);
  605. psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW|PSH_PROPTITLE;
  606. psh.hwndParent = hwnd;
  607. psh.pszCaption = GetStringInfo(pcpidl, SI_CONTROL);
  608. psh.nPages = NUM_PAGES;
  609. psh.nStartPage = 0;
  610. psh.ppsp = (LPCPROPSHEETPAGE)&psp;
  611. // invoke the property sheet
  612. PropertySheet(&psh);
  613. return NOERROR;
  614. }