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.

2345 lines
71 KiB

  1. // MsieCtl.cpp : Implementation of the CMsieCtrl ActiveX Control class.
  2. #include "stdafx.h"
  3. #include "Msie.h"
  4. #include "MsieCtl.h"
  5. #include "MsiePpg.h"
  6. #include "MsieData.h"
  7. #include "resdefs.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. // WMI Interfaces used (defining here instead of linking to wbemuuid.lib)
  14. const IID IID_IWbemProviderInit =
  15. { 0x1be41572, 0x91dd, 0x11d1, { 0xae, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20 } };
  16. //const IID IID_IWbemServices =
  17. // { 0x9556dc99, 0x828c, 0x11cf, { 0xa3, 0x7e, 0x00, 0xaa, 0x00, 0x32, 0x40, 0xc7 } };
  18. // Macro for setting a WBEM property
  19. #define SETPROPERTY(prop) \
  20. if (pData->prop.vt == VT_DATE) \
  21. ConvertDateToWbemString(pData->prop); \
  22. pInstance->Put(L#prop, 0, &pData->prop, 0);
  23. IMPLEMENT_DYNCREATE(CMsieCtrl, COleControl)
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Message map
  26. BEGIN_MESSAGE_MAP(CMsieCtrl, COleControl)
  27. //{{AFX_MSG_MAP(CMsieCtrl)
  28. ON_WM_CREATE()
  29. ON_WM_SIZE()
  30. ON_WM_CTLCOLOR()
  31. ON_BN_CLICKED(IDC_BTN_BASIC, OnBasicBtnClicked)
  32. ON_BN_CLICKED(IDC_BTN_ADVANCED, OnAdvancedBtnClicked)
  33. //}}AFX_MSG_MAP
  34. ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Dispatch map
  38. BEGIN_DISPATCH_MAP(CMsieCtrl, COleControl)
  39. //{{AFX_DISPATCH_MAP(CMsieCtrl)
  40. DISP_PROPERTY_NOTIFY(CMsieCtrl, "MSInfoView", m_MSInfoView, OnMSInfoViewChanged, VT_I4)
  41. DISP_FUNCTION(CMsieCtrl, "MSInfoRefresh", MSInfoRefresh, VT_EMPTY, VTS_BOOL VTS_PI4)
  42. DISP_FUNCTION(CMsieCtrl, "MSInfoLoadFile", MSInfoLoadFile, VT_BOOL, VTS_BSTR)
  43. DISP_FUNCTION(CMsieCtrl, "MSInfoSelectAll", MSInfoSelectAll, VT_EMPTY, VTS_NONE)
  44. DISP_FUNCTION(CMsieCtrl, "MSInfoCopy", MSInfoCopy, VT_EMPTY, VTS_NONE)
  45. DISP_FUNCTION(CMsieCtrl, "MSInfoUpdateView", MSInfoUpdateView, VT_EMPTY, VTS_NONE)
  46. DISP_FUNCTION(CMsieCtrl, "MSInfoGetData", MSInfoGetData, VT_I4, VTS_I4 VTS_PI4 VTS_I4)
  47. //}}AFX_DISPATCH_MAP
  48. END_DISPATCH_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // Interface map
  51. BEGIN_INTERFACE_MAP(CMsieCtrl, COleControl)
  52. INTERFACE_PART(CMsieCtrl, IID_IWbemProviderInit, WbemProviderInit)
  53. INTERFACE_PART(CMsieCtrl, IID_IWbemServices, WbemServices)
  54. END_INTERFACE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // Event map
  57. BEGIN_EVENT_MAP(CMsieCtrl, COleControl)
  58. //{{AFX_EVENT_MAP(CMsieCtrl)
  59. //}}AFX_EVENT_MAP
  60. END_EVENT_MAP()
  61. /////////////////////////////////////////////////////////////////////////////
  62. // Property pages
  63. BEGIN_PROPPAGEIDS(CMsieCtrl, 1)
  64. PROPPAGEID(CMsiePropPage::guid)
  65. END_PROPPAGEIDS(CMsieCtrl)
  66. /////////////////////////////////////////////////////////////////////////////
  67. // Initialize class factory and guid
  68. IMPLEMENT_OLECREATE_EX(CMsieCtrl, "MSIE.MsieCtrl.1",
  69. 0x25959bef, 0xe700, 0x11d2, 0xa7, 0xaf, 0, 0xc0, 0x4f, 0x80, 0x62, 0)
  70. /////////////////////////////////////////////////////////////////////////////
  71. // Type library ID and version
  72. IMPLEMENT_OLETYPELIB(CMsieCtrl, _tlid, _wVerMajor, _wVerMinor)
  73. /////////////////////////////////////////////////////////////////////////////
  74. // Interface IDs
  75. const IID BASED_CODE IID_DMsie =
  76. { 0x25959bed, 0xe700, 0x11d2, { 0xa7, 0xaf, 0, 0xc0, 0x4f, 0x80, 0x62, 0 } };
  77. const IID BASED_CODE IID_DMsieEvents =
  78. { 0x25959bee, 0xe700, 0x11d2, { 0xa7, 0xaf, 0, 0xc0, 0x4f, 0x80, 0x62, 0 } };
  79. /////////////////////////////////////////////////////////////////////////////
  80. // Control type information
  81. static const DWORD BASED_CODE _dwMsieOleMisc =
  82. OLEMISC_SIMPLEFRAME |
  83. OLEMISC_INVISIBLEATRUNTIME |
  84. OLEMISC_ACTIVATEWHENVISIBLE |
  85. OLEMISC_SETCLIENTSITEFIRST |
  86. OLEMISC_INSIDEOUT |
  87. OLEMISC_CANTLINKINSIDE |
  88. OLEMISC_RECOMPOSEONRESIZE;
  89. IMPLEMENT_OLECTLTYPE(CMsieCtrl, IDS_MSIE, _dwMsieOleMisc)
  90. /////////////////////////////////////////////////////////////////////////////
  91. // CMsieCtrl::CMsieCtrlFactory::UpdateRegistry -
  92. // Adds or removes system registry entries for CMsieCtrl
  93. BOOL CMsieCtrl::CMsieCtrlFactory::UpdateRegistry(BOOL bRegister)
  94. {
  95. // TODO: Verify that your control follows apartment-model threading rules.
  96. // Refer to MFC TechNote 64 for more information.
  97. // If your control does not conform to the apartment-model rules, then
  98. // you must modify the code below, changing the 6th parameter from
  99. // afxRegApartmentThreading to 0.
  100. if (bRegister)
  101. return AfxOleRegisterControlClass(
  102. AfxGetInstanceHandle(),
  103. m_clsid,
  104. m_lpszProgID,
  105. IDS_MSIE,
  106. IDB_MSIE,
  107. afxRegApartmentThreading,
  108. _dwMsieOleMisc,
  109. _tlid,
  110. _wVerMajor,
  111. _wVerMinor);
  112. else
  113. return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
  114. }
  115. /////////////////////////////////////////////////////////////////////////////
  116. // CMsieCtrl::CMsieCtrl - Constructor
  117. CMsieCtrl::CMsieCtrl()
  118. {
  119. TRACE0("-- CMsieCtrl::CMsieCtrl()\n");
  120. InitializeIIDs(&IID_DMsie, &IID_DMsieEvents);
  121. EnableSimpleFrame();
  122. // set background brush to white (used with static and radio button controls)
  123. m_pCtlBkBrush = new CBrush(RGB(255,255,255));
  124. // You don't need to initialize your data members here. In fact, you
  125. // shouldn't do any time consuming updates here. MSInfoRefresh will
  126. // be called before you need to render or save information.
  127. //
  128. // You will want to initialize the member variable which indicates
  129. // that the control is showing current system info (not any loaded
  130. // information) as this is the default.
  131. m_bCurrent = true;
  132. m_cColumns = 0;
  133. m_MSInfoView = 0;
  134. m_pNamespace = NULL;
  135. }
  136. /////////////////////////////////////////////////////////////////////////////
  137. // CMsieCtrl::~CMsieCtrl - Destructor
  138. CMsieCtrl::~CMsieCtrl()
  139. {
  140. TRACE0("-- CMsieCtrl::~CMsieCtrl()\n");
  141. // Delete all of the items in the pointer array.
  142. for (int i = 0; i < m_ptrarray.GetSize(); i++)
  143. DeleteArrayObject(m_ptrarray.GetAt(i));
  144. m_ptrarray.RemoveAll();
  145. delete m_pCtlBkBrush;
  146. if (m_pNamespace)
  147. m_pNamespace->Release();
  148. }
  149. /////////////////////////////////////////////////////////////////////////////
  150. // CMsieCtrl::OnDraw - Drawing function
  151. void CMsieCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
  152. {
  153. TRACE0("-- CMsieCtrl::OnDraw()\n");
  154. if (m_MSInfoView)
  155. {
  156. if (m_MSInfoView == MSIVIEW_CONNECTIVITY)
  157. {
  158. DrawLine();
  159. m_edit.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME);
  160. }
  161. else
  162. m_list.RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME);
  163. }
  164. }
  165. /////////////////////////////////////////////////////////////////////////////
  166. // CMsieCtrl::DoPropExchange - Persistence support
  167. void CMsieCtrl::DoPropExchange(CPropExchange* pPX)
  168. {
  169. ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
  170. COleControl::DoPropExchange(pPX);
  171. // Not using properties, so I'll just leave this one alone.
  172. }
  173. /////////////////////////////////////////////////////////////////////////////
  174. // CMsieCtrl::OnResetState - Reset control to default state
  175. void CMsieCtrl::OnResetState()
  176. {
  177. COleControl::OnResetState(); // Resets defaults found in DoPropExchange
  178. }
  179. //-----------------------------------------------------------------------------
  180. // The OnCreate method is used to create the list control. Also, if we've
  181. // already loaded information using Serialize, we can add the lines to
  182. // the list control.
  183. //-----------------------------------------------------------------------------
  184. int CMsieCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
  185. {
  186. TRACE0("-- CMsieCtrl::OnCreate()\n");
  187. CRect rect;
  188. DWORD dwExStyles;
  189. CString strText;
  190. CHARFORMAT cf;
  191. NONCLIENTMETRICS ncm;
  192. // setup fonts for static and radio button controls
  193. memset(&ncm, 0, sizeof(ncm));
  194. ncm.cbSize = sizeof(ncm);
  195. SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  196. ncm.lfMessageFont.lfWeight = FW_BOLD;
  197. m_fontStatic.CreateFontIndirect(&ncm.lfMessageFont);
  198. ncm.lfMessageFont.lfWeight = FW_NORMAL;
  199. m_fontBtn.CreateFontIndirect(&ncm.lfMessageFont);
  200. if (COleControl::OnCreate(lpCreateStruct) == -1) return -1;
  201. // In this control, we want to process the WM_CREATE message so we
  202. // can create the list control which is used to display the print
  203. // information. Make the list control the same size as the
  204. // client area.
  205. GetClientRect(&rect);
  206. if (!m_list.Create(WS_CHILD | WS_VSCROLL | WS_HSCROLL | LVS_REPORT, rect, this, IDC_LISTCTRL))
  207. return -1;
  208. // set to FullRowSelect (via extended style)
  209. dwExStyles = (DWORD) ::SendMessage(m_list.m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
  210. ::SendMessage(m_list.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwExStyles | LVS_EX_FULLROWSELECT);
  211. // create static text for Connectivity node
  212. strText.LoadString(IDS_CONNECTIVITY);
  213. if (!m_static.Create(strText, WS_CHILD | WS_GROUP | WS_EX_TRANSPARENT | SS_LEFT, CRect(rect.left + 5, rect.top, rect.left + 100, rect.top + 20), this, IDC_STATIC))
  214. return -1;
  215. m_static.SetFont(&m_fontStatic);
  216. // create basic and advanced radio buttons for Connectivity node
  217. strText.LoadString(IDS_BASIC_INFO);
  218. if (!m_btnBasic.Create(strText, WS_CHILD | WS_TABSTOP | WS_GROUP | BS_AUTORADIOBUTTON, CRect(rect.left + 5, rect.top + 25, rect.left + 200, rect.top + 45), this, IDC_BTN_BASIC))
  219. return -1;
  220. m_btnBasic.SetFont(&m_fontBtn);
  221. m_btnBasic.SetCheck(1);
  222. strText.LoadString(IDS_ADVANCED_INFO);
  223. if (!m_btnAdvanced.Create(strText, WS_CHILD | BS_AUTORADIOBUTTON, CRect(rect.left + 200, rect.top + 25, rect.left + 400, rect.top + 45), this, IDC_BTN_ADVANCED))
  224. return -1;
  225. m_btnAdvanced.SetFont(&m_fontBtn);
  226. // create a rich edit control for display Connectivity node
  227. if (!m_edit.Create(WS_CHILD | WS_CLIPCHILDREN | WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_HSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_SAVESEL | ES_READONLY, CRect(rect.left, rect.top + 63, rect.right, rect.bottom), this, IDC_EDITCTRL))
  228. return -1;
  229. // set default character formatting for rich edit control
  230. cf.cbSize = sizeof(cf);
  231. cf.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_SIZE;
  232. cf.dwEffects = CFE_AUTOCOLOR;
  233. cf.yHeight = 180;
  234. strcpy(cf.szFaceName, "MS Sans Serif");
  235. m_edit.SetDefaultCharFormat(cf);
  236. return 0;
  237. }
  238. void CMsieCtrl::DrawLine()
  239. {
  240. CRect rect;
  241. CDC *dc = GetDC();
  242. CBrush brush;
  243. GetClientRect(&rect);
  244. brush.CreateSolidBrush(GetBkColor(*dc));
  245. dc->FillRect(rect, &brush);
  246. dc->MoveTo(0, 61);
  247. dc->LineTo(rect.Width(), 61);
  248. dc->MoveTo(0, 62);
  249. dc->LineTo(rect.Width(), 62);
  250. ReleaseDC(dc);
  251. }
  252. //-----------------------------------------------------------------------------
  253. // The FormatColumns method makes calls to the AddColumn method to create
  254. // all of the necessary columns for this control.
  255. //-----------------------------------------------------------------------------
  256. BOOL CMsieCtrl::FormatColumns()
  257. {
  258. TRACE1("-- CMsieCtrl::FormatColumns: %i\n", m_MSInfoView);
  259. int idsCol1, idsCol2;
  260. // remove current columns
  261. for (int iCol = m_cColumns - 1; iCol >= 0; iCol--)
  262. m_list.DeleteColumn(iCol);
  263. m_cColumns = 0;
  264. if (m_MSInfoView == MSIVIEW_FILE_VERSIONS)
  265. {
  266. // File, Version, Size, Date, Path, Company
  267. AddColumn(IDS_FILE, 0, 17);
  268. AddColumn(IDS_VERSION, 1, 17);
  269. AddColumn(IDS_SIZE, 2, 17, 0, LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM, LVCFMT_RIGHT);
  270. AddColumn(IDS_DATE, 3, 17);
  271. AddColumn(IDS_PATH, 4, 17);
  272. AddColumn(IDS_COMPANY, 5, -1);
  273. }
  274. else if (m_MSInfoView == MSIVIEW_OBJECT_LIST)
  275. {
  276. AddColumn(IDS_PROGRAM_FILE, 0, 40);
  277. AddColumn(IDS_STATUS, 1, 20);
  278. AddColumn(IDS_CODE_BASE, 5, -1);
  279. }
  280. else if ((m_MSInfoView == MSIVIEW_PERSONAL_CERTIFICATES) || (m_MSInfoView == MSIVIEW_OTHER_PEOPLE_CERTIFICATES))
  281. {
  282. AddColumn(IDS_ISSUED_TO, 0, 30);
  283. AddColumn(IDS_ISSUED_BY, 1, 30);
  284. AddColumn(IDS_VALIDITY, 5, 20);
  285. AddColumn(IDS_SIGNATURE_ALGORITHM, 5, -1);
  286. }
  287. else if (m_MSInfoView == MSIVIEW_PUBLISHERS)
  288. {
  289. AddColumn(IDS_NAME, 0, -1);
  290. }
  291. else
  292. {
  293. if (m_MSInfoView == MSIVIEW_SECURITY)
  294. {
  295. idsCol1 = IDS_ZONE;
  296. idsCol2 = IDS_SECURITY_LEVEL;
  297. }
  298. else
  299. {
  300. idsCol1 = IDS_ITEM;
  301. idsCol2 = IDS_VALUE;
  302. }
  303. // Item, Value
  304. // The item lable gets 40% of the control width, the value label the rest.
  305. AddColumn(idsCol1, 0, 40);
  306. AddColumn(idsCol2, 1, -1);
  307. }
  308. return TRUE;
  309. }
  310. //-----------------------------------------------------------------------------
  311. // The AddColumn method adds (you guessed it) a column to the list control. If
  312. // size is zero, the column is sized large enough to hold the text. If size is
  313. // positive, it is treated as a percentage of the window width. If size is -1,
  314. // the column is sized to fill the remaining space in the window.
  315. //-----------------------------------------------------------------------------
  316. BOOL CMsieCtrl::AddColumn(int idsLabel, int nItem, int size, int nSubItem, int nMask, int nFmt)
  317. {
  318. LV_COLUMN lvc, getlvc;
  319. CString strLabel;
  320. CRect rect;
  321. int nIndex, spaceUsed = 0, nCol = 0;
  322. strLabel.LoadString(idsLabel);
  323. // strip off W2K "[]" stuff
  324. if (-1 != (nIndex = strLabel.Find(_T('['))))
  325. strLabel = strLabel.Left(nIndex - 1);
  326. lvc.mask = nMask;
  327. lvc.fmt = nFmt;
  328. lvc.pszText = (LPTSTR)(LPCTSTR)strLabel;
  329. // Save the ratio for this column.
  330. ASSERT(nItem < 20);
  331. m_aiRequestedWidths[nItem] = size;
  332. if (m_cColumns < nItem + 1)
  333. m_cColumns = nItem + 1;
  334. // Determine the size of this new column.
  335. switch (size)
  336. {
  337. case 0: // shouldn't use this, though.
  338. lvc.cx = m_list.GetStringWidth(lvc.pszText) + 15;
  339. break;
  340. case -1:
  341. getlvc.mask = LVCF_WIDTH;
  342. for (nCol = 0; m_list.GetColumn(nCol, &getlvc); nCol++)
  343. spaceUsed += getlvc.cx;
  344. m_list.GetClientRect(&rect);
  345. lvc.cx = rect.Width() - spaceUsed;
  346. break;
  347. default:
  348. m_list.GetClientRect(&rect);
  349. lvc.cx = (rect.Width() * size) / 100;
  350. }
  351. if (nMask & LVCF_SUBITEM)
  352. {
  353. if (nSubItem != -1)
  354. lvc.iSubItem = nSubItem;
  355. else
  356. lvc.iSubItem = nItem;
  357. }
  358. m_aiColumnWidths[nItem] = lvc.cx;
  359. m_aiMaxWidths[nItem] = lvc.cx;
  360. m_aiMinWidths[nItem] = lvc.cx;
  361. return m_list.InsertColumn(nItem, &lvc);
  362. }
  363. //-----------------------------------------------------------------------------
  364. // The RefigureColumns method is called when the control is resized. It should
  365. // use the information saved about the columns to change their widths. We
  366. // assume that the last column should be sized to fit the remaining space, if
  367. // possible. Here are our resizing rules:
  368. //
  369. // 1. If the user has resized something, LEAVE THAT WIDTH ALONE.
  370. // 2. Otherwise, use the ratios originally set.
  371. // 3. If a column's wider than its widest item, use the widest item.
  372. // 4. If a column's smaller than its minimum width, use the min.
  373. // 5. Always size the last column to fit, unless it would be smaller
  374. // than its minimum.
  375. //-----------------------------------------------------------------------------
  376. void CMsieCtrl::RefigureColumns(CRect& rect)
  377. {
  378. int iCol, iPercentageLeft, cxAvailable, cxTotal, cxWidth;
  379. BOOL bIgnoreColumn[20];
  380. if (rect == CRect(0,0,0,0))
  381. m_list.GetClientRect(&rect);
  382. // Initialize the running totals.
  383. iPercentageLeft = 100;
  384. cxAvailable = rect.Width();
  385. // The first pass will be used to find out what columns to leave alone.
  386. // Doing this allows us to use make a better estimate of the other
  387. // column's size using the ratios.
  388. for (iCol = 0; iCol < m_cColumns; iCol++)
  389. {
  390. if (m_list.GetColumnWidth(iCol) != m_aiColumnWidths[iCol])
  391. {
  392. cxAvailable -= m_list.GetColumnWidth(iCol);
  393. iPercentageLeft -= m_aiRequestedWidths[iCol];
  394. bIgnoreColumn[iCol] = TRUE;
  395. }
  396. else
  397. bIgnoreColumn[iCol] = FALSE;
  398. }
  399. cxTotal = cxAvailable;
  400. // Now, resize the rest of the columns.
  401. for (iCol = 0; iCol < m_cColumns; iCol++)
  402. {
  403. if (bIgnoreColumn[iCol])
  404. continue;
  405. // Compute how big this column should be, based on the space
  406. // remaining. Remember, cxTotal is the total remaining space
  407. // left after the fixed size columns have been accounted for.
  408. if (iCol + 1 < m_cColumns)
  409. {
  410. cxWidth = m_aiRequestedWidths[iCol] * cxAvailable / iPercentageLeft;
  411. iPercentageLeft -= m_aiRequestedWidths[iCol];
  412. if (cxWidth > m_aiMaxWidths[iCol]) cxWidth = m_aiMaxWidths[iCol];
  413. if (cxWidth < m_aiMinWidths[iCol]) cxWidth = m_aiMinWidths[iCol];
  414. }
  415. else
  416. {
  417. // This is the last column. Try out using the space available.
  418. cxWidth = cxAvailable;
  419. if (cxWidth < m_aiMinWidths[iCol]) cxWidth = m_aiMinWidths[iCol];
  420. }
  421. // if first column, add space for icon
  422. if (!iCol)
  423. cxWidth += 20;
  424. cxAvailable -= cxWidth;
  425. m_list.SetColumnWidth(iCol, cxWidth);
  426. m_aiColumnWidths[iCol] = m_list.GetColumnWidth(iCol);
  427. }
  428. }
  429. //-----------------------------------------------------------------------------
  430. // The AddItem method is used to add a line to the list control.
  431. //-----------------------------------------------------------------------------
  432. BOOL CMsieCtrl::AddItem(int nItem, int nSubItem, LPCTSTR strItem, int nImageIndex)
  433. {
  434. LV_ITEM lvItem;
  435. lvItem.mask = LVIF_TEXT;
  436. lvItem.iItem = nItem;
  437. lvItem.iSubItem = nSubItem;
  438. lvItem.pszText = (LPTSTR)strItem;
  439. if (nSubItem == 0)
  440. {
  441. if (nImageIndex != -1)
  442. {
  443. lvItem.mask |= LVIF_IMAGE;
  444. lvItem.iImage = nImageIndex;
  445. }
  446. return m_list.InsertItem(&lvItem);
  447. }
  448. return m_list.SetItem(&lvItem);
  449. }
  450. //-----------------------------------------------------------------------------
  451. // MSInfo Specific...
  452. //
  453. // When the view property is changed, we should update whatever
  454. // variables used to display the information so the new view will
  455. // be reflected when the control is redrawn, or when data is returned
  456. // by the MSInfoGetText method. This method should NOT refresh the
  457. // information from the system (that's what MSInfoRefresh is for) or
  458. // cause the control to redraw itself.
  459. //-----------------------------------------------------------------------------
  460. void CMsieCtrl::OnMSInfoViewChanged()
  461. {
  462. TRACE1("-- CMsieCtrl::OnMSInfoViewChanged() [changed to %ld]\n", m_MSInfoView);
  463. }
  464. void CMsieCtrl::DeleteArrayObject(void *ptrArray)
  465. {
  466. LIST_ITEM *pListItem;
  467. LIST_FILE_VERSION *pFileVersion;
  468. LIST_OBJECT *pObject;
  469. LIST_CERT *pCert;
  470. LIST_NAME *pName;
  471. EDIT_ITEM *pEditItem;
  472. if (ptrArray)
  473. {
  474. switch (m_MSInfoView)
  475. {
  476. case MSIVIEW_FILE_VERSIONS:
  477. pFileVersion = (LIST_FILE_VERSION *)ptrArray;
  478. delete pFileVersion;
  479. break;
  480. case MSIVIEW_OBJECT_LIST:
  481. pObject = (LIST_OBJECT *)ptrArray;
  482. delete pObject;
  483. break;
  484. case MSIVIEW_CONNECTIVITY:
  485. pEditItem = (EDIT_ITEM *)ptrArray;
  486. delete pEditItem;
  487. break;
  488. case MSIVIEW_PERSONAL_CERTIFICATES:
  489. case MSIVIEW_OTHER_PEOPLE_CERTIFICATES:
  490. pCert = (LIST_CERT *)ptrArray;
  491. delete pCert;
  492. break;
  493. case MSIVIEW_PUBLISHERS:
  494. pName = (LIST_NAME *)ptrArray;
  495. delete pName;
  496. break;
  497. default:
  498. pListItem = (LIST_ITEM *)ptrArray;
  499. delete pListItem;
  500. }
  501. }
  502. }
  503. //-----------------------------------------------------------------------------
  504. // MSInfo Specific...
  505. //
  506. // The MSInfoRefresh method is where the bulk of the work will be
  507. // done for your control. You should requery the system for all of the
  508. // information you display. If this query has the potential to be
  509. // at all time consuming, monitor the long pointed to by pCancel.
  510. // If it is ever non-zero, cancel the update. If the update is
  511. // cancelled, the control is responsible for restoring itself to the
  512. // original, pre-refresh state.
  513. //
  514. // This method should never be called if the control is displaying
  515. // previously saved information.
  516. //
  517. // If the fForSave parameter is TRUE, then the control is being
  518. // updated prior to saving to a stream. In this case, ALL information
  519. // should be gathered (not just info relevant to the current
  520. // MSInfoView) and the control should not be redrawn. Otherwise, for
  521. // efficiency, you can update information only shown by the current
  522. // view.
  523. //-----------------------------------------------------------------------------
  524. void CMsieCtrl::MSInfoRefresh(BOOL fForSave, long FAR* pCancel)
  525. {
  526. TRACE1("-- CMsieCtrl::MSInfoRefresh(%s,...)\n", (fForSave) ? "TRUE" : "FALSE");
  527. CPtrArray ptrarrayNew;
  528. int i, iListItem;
  529. if (!m_bCurrent) return;
  530. // Remember, we need to check if the update was cancelled. It's a good idea
  531. // to check before we start the update, in case it was cancelled while the
  532. // control was being loaded.
  533. if (*pCancel != 0L) return;
  534. // Call a method to update the new pointer array with current info, based
  535. // on what view we should be showing.
  536. iListItem = 0;
  537. if (fForSave)
  538. {
  539. for (i = MSIVIEW_BEGIN; i <= MSIVIEW_END; i++)
  540. RefreshArray(i, iListItem, ptrarrayNew);
  541. }
  542. else
  543. RefreshArray(m_MSInfoView, iListItem, ptrarrayNew);
  544. // If this loop has been broken out of because of a cancel, then
  545. // deallocate all of the structures we've allocated for the list
  546. // and exit. If we're still OK, copy all of the new items over
  547. // to the real pointer array (deallocating what's already there).
  548. if (*pCancel == 0L)
  549. {
  550. i = 0;
  551. while (i < ptrarrayNew.GetSize())
  552. {
  553. // Delete what's already in the list (if there is anything
  554. // in the list).
  555. if (i < m_ptrarray.GetSize())
  556. DeleteArrayObject(m_ptrarray.GetAt(i));
  557. // Copy the element from the new array to the real array.
  558. m_ptrarray.SetAtGrow(i++, ptrarrayNew.GetAt(i));
  559. }
  560. // Finish emptying out the list (if necessary).
  561. while (i < m_ptrarray.GetSize())
  562. {
  563. DeleteArrayObject(m_ptrarray.GetAt(i));
  564. m_ptrarray.SetAt(i++, NULL);
  565. }
  566. }
  567. else
  568. {
  569. // Delete all of the items in the pointer array.
  570. for (int i = 0; i < ptrarrayNew.GetSize(); i++)
  571. DeleteArrayObject(ptrarrayNew.GetAt(i));
  572. ptrarrayNew.RemoveAll();
  573. }
  574. }
  575. void CMsieCtrl::RefreshArray(int iView, int &iListItem, CPtrArray &ptrarrayNew)
  576. {
  577. TRACE0("-- CMsieCtrl::RefreshArray\n");
  578. long lCount, lIndex;
  579. m_uiView = iView;
  580. if (iView == MSIVIEW_SUMMARY)
  581. {
  582. IE_SUMMARY **ppData;
  583. CString strVersion;
  584. theApp.AppGetIEData(SummaryType, &lCount, (void***)&ppData);
  585. if (lCount == 1)
  586. {
  587. AddToArray(ptrarrayNew, iListItem++, IDS_VERSION, GetStringFromVariant((*ppData)->Version));
  588. AddToArray(ptrarrayNew, iListItem++, IDS_BUILD, GetStringFromVariant((*ppData)->Build));
  589. AddToArray(ptrarrayNew, iListItem++, IDS_PRODUCT_ID, GetStringFromVariant((*ppData)->ProductID));
  590. AddToArray(ptrarrayNew, iListItem++, IDS_APP_PATH, GetStringFromVariant((*ppData)->Path));
  591. AddToArray(ptrarrayNew, iListItem++, IDS_LAST_INSTALL_DATE, GetStringFromVariant((*ppData)->LastInstallDate));
  592. AddToArray(ptrarrayNew, iListItem++, IDS_LANGUAGE, GetStringFromVariant((*ppData)->Language));
  593. AddToArray(ptrarrayNew, iListItem++, IDS_ACTIVE_PRINTER, GetStringFromVariant((*ppData)->ActivePrinter));
  594. AddBlankLineToArray(ptrarrayNew, iListItem++);
  595. AddToArray(ptrarrayNew, iListItem++, IDS_CIPHER_STRENGTH, GetStringFromVariant((*ppData)->CipherStrength, IDS_FORMAT_BIT));
  596. AddToArray(ptrarrayNew, iListItem++, IDS_CONTENT_ADVISOR, GetStringFromVariant((*ppData)->ContentAdvisor));
  597. AddToArray(ptrarrayNew, iListItem++, IDS_IEAK_INSTALL, GetStringFromVariant((*ppData)->IEAKInstall));
  598. }
  599. theApp.AppDeleteIEData(SummaryType, lCount, (void**)ppData);
  600. }
  601. else if (iView == MSIVIEW_FILE_VERSIONS)
  602. {
  603. IE_FILE_VERSION **ppData;
  604. theApp.AppGetIEData(FileVersionType, &lCount, (void***)&ppData);
  605. for (lIndex = 0; lIndex < lCount; lIndex++)
  606. {
  607. AddFileVersionToArray(ptrarrayNew, iListItem++,
  608. GetStringFromVariant(ppData[lIndex]->File),
  609. GetStringFromVariant(ppData[lIndex]->Version),
  610. GetStringFromVariant(ppData[lIndex]->Size, IDS_FORMAT_KB),
  611. GetStringFromVariant(ppData[lIndex]->Date),
  612. GetStringFromVariant(ppData[lIndex]->Path),
  613. GetStringFromVariant(ppData[lIndex]->Company),
  614. ppData[lIndex]->Size.lVal,
  615. ppData[lIndex]->Date.date);
  616. }
  617. theApp.AppDeleteIEData(FileVersionType, lCount, (void**)ppData);
  618. }
  619. else if (iView == MSIVIEW_CONNECTIVITY)
  620. {
  621. IE_CONN_SUMMARY **ppData;
  622. IE_LAN_SETTINGS **ppLanData;
  623. IE_CONN_SETTINGS **ppConnData;
  624. CString strTemp;
  625. long lLanCount, lConnCount;
  626. theApp.AppGetIEData(ConnSummaryType, &lCount, (void***)&ppData);
  627. if (lCount == 1)
  628. {
  629. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  630. AddEditToArray(ptrarrayNew, iListItem++, IDS_CONN_PREF, GetStringFromVariant((*ppData)->ConnectionPreference));
  631. AddEditToArray(ptrarrayNew, iListItem++, IDS_ENABLE_HTTP_1_1, GetStringFromVariant((*ppData)->EnableHttp11));
  632. AddEditToArray(ptrarrayNew, iListItem++, IDS_PROXY_HTTP_1_1, GetStringFromVariant((*ppData)->ProxyHttp11));
  633. }
  634. theApp.AppDeleteIEData(ConnSummaryType, lCount, (void**)ppData);
  635. theApp.AppGetIEData(LanSettingsType, &lLanCount, (void***)&ppLanData);
  636. if (lCount == 1)
  637. {
  638. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  639. AddEditToArray(ptrarrayNew, iListItem++, IDS_LAN_SETTINGS, _T(""), TRUE);
  640. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  641. AddEditToArray(ptrarrayNew, iListItem++, IDS_AUTO_CONFIG_PROXY, GetStringFromVariant((*ppLanData)->AutoConfigProxy));
  642. AddEditToArray(ptrarrayNew, iListItem++, IDS_AUTO_PROXY_DETECT_MODE, GetStringFromVariant((*ppLanData)->AutoProxyDetectMode));
  643. AddEditToArray(ptrarrayNew, iListItem++, IDS_AUTO_CONFIG_URL, GetStringFromVariant((*ppLanData)->AutoConfigURL));
  644. AddEditToArray(ptrarrayNew, iListItem++, IDS_PROXY, GetStringFromVariant((*ppLanData)->Proxy));
  645. AddEditToArray(ptrarrayNew, iListItem++, IDS_PROXY_SERVER, GetStringFromVariant((*ppLanData)->ProxyServer));
  646. AddEditToArray(ptrarrayNew, iListItem++, IDS_PROXY_OVERRIDE, GetStringFromVariant((*ppLanData)->ProxyOverride));
  647. }
  648. theApp.AppDeleteIEData(LanSettingsType, lLanCount, (void**)ppLanData);
  649. theApp.AppGetIEData(ConnSettingsType, &lConnCount, (void***)&ppConnData);
  650. if (lConnCount > 0)
  651. {
  652. for (lIndex = 0; lIndex < lConnCount; lIndex++)
  653. {
  654. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  655. AddEditToArray(ptrarrayNew, iListItem++, GetStringFromVariant(ppConnData[lIndex]->Name), _T(""), TRUE);
  656. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  657. AddEditToArray(ptrarrayNew, iListItem++, IDS_AUTO_PROXY_DETECT_MODE, GetStringFromVariant(ppConnData[lIndex]->AutoProxyDetectMode));
  658. AddEditToArray(ptrarrayNew, iListItem++, IDS_AUTO_CONFIG_URL, GetStringFromVariant(ppConnData[lIndex]->AutoConfigURL));
  659. AddEditToArray(ptrarrayNew, iListItem++, IDS_PROXY, GetStringFromVariant(ppConnData[lIndex]->Proxy));
  660. AddEditToArray(ptrarrayNew, iListItem++, IDS_PROXY_SERVER, GetStringFromVariant(ppConnData[lIndex]->ProxyServer));
  661. AddEditToArray(ptrarrayNew, iListItem++, IDS_PROXY_OVERRIDE, GetStringFromVariant(ppConnData[lIndex]->ProxyOverride));
  662. AddEditToArray(ptrarrayNew, iListItem++, IDS_ALLOW_INTERNET_PROGRAMS, GetStringFromVariant(ppConnData[lIndex]->AllowInternetPrograms));
  663. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  664. AddEditToArray(ptrarrayNew, iListItem++, IDS_MAX_ATTEMPTS, GetStringFromVariant(ppConnData[lIndex]->RedialAttempts));
  665. AddEditToArray(ptrarrayNew, iListItem++, IDS_WAIT_BETWEEN_ATTEMPTS, GetStringFromVariant(ppConnData[lIndex]->RedialWait));
  666. AddEditToArray(ptrarrayNew, iListItem++, IDS_DISCONNECT_IDLE_TIME, GetStringFromVariant(ppConnData[lIndex]->DisconnectIdleTime));
  667. AddEditToArray(ptrarrayNew, iListItem++, IDS_AUTO_DISCONNECT, GetStringFromVariant(ppConnData[lIndex]->AutoDisconnect));
  668. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  669. AddEditToArray(ptrarrayNew, iListItem++, IDS_MODEM, GetStringFromVariant(ppConnData[lIndex]->Modem));
  670. AddEditToArray(ptrarrayNew, iListItem++, IDS_DIAL_UP_SERVER, GetStringFromVariant(ppConnData[lIndex]->DialUpServer));
  671. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  672. AddEditToArray(ptrarrayNew, iListItem++, IDS_LOG_ON_TO_NETWORK, GetStringFromVariant(ppConnData[lIndex]->NetworkLogon));
  673. AddEditToArray(ptrarrayNew, iListItem++, IDS_ENABLE_SOFTWARE_COMPRESSION, GetStringFromVariant(ppConnData[lIndex]->SoftwareCompression));
  674. AddEditToArray(ptrarrayNew, iListItem++, IDS_REQUIRE_ENCRYPTED_PASSWORD, GetStringFromVariant(ppConnData[lIndex]->EncryptedPassword));
  675. AddEditToArray(ptrarrayNew, iListItem++, IDS_REQUIRE_DATA_ENCRYPTION, GetStringFromVariant(ppConnData[lIndex]->DataEncryption));
  676. AddEditToArray(ptrarrayNew, iListItem++, IDS_RECORD_LOG_FILE, GetStringFromVariant(ppConnData[lIndex]->RecordLogFile));
  677. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  678. AddEditToArray(ptrarrayNew, iListItem++, IDS_NETWORK_PROTOCOLS, GetStringFromVariant(ppConnData[lIndex]->NetworkProtocols));
  679. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  680. AddEditToArray(ptrarrayNew, iListItem++, IDS_USE_SERVER_ASSIGNED_IP_ADDRESS, GetStringFromVariant(ppConnData[lIndex]->ServerAssignedIPAddress));
  681. AddEditToArray(ptrarrayNew, iListItem++, IDS_IP_ADDRESS, GetStringFromVariant(ppConnData[lIndex]->IPAddress));
  682. AddEditToArray(ptrarrayNew, iListItem++, IDS_USE_SERVER_ASSIGNED_NAME_SERVER, GetStringFromVariant(ppConnData[lIndex]->ServerAssignedNameServer));
  683. strTemp.Format(IDS_PRIMARY_DNS, GetStringFromVariant(ppConnData[lIndex]->PrimaryDNS));
  684. AddEditToArray(ptrarrayNew, iListItem++, IDS_NAME_SERVER_ADDRESSES, strTemp);
  685. strTemp.Format(IDS_SECONDARY_DNS, GetStringFromVariant(ppConnData[lIndex]->SecondaryDNS));
  686. AddEditToArray(ptrarrayNew, iListItem++, _T(""), strTemp);
  687. strTemp.Format(IDS_PRIMARY_WINS, GetStringFromVariant(ppConnData[lIndex]->PrimaryWINS));
  688. AddEditToArray(ptrarrayNew, iListItem++, _T(""), strTemp);
  689. strTemp.Format(IDS_SECONDARY_WINS, GetStringFromVariant(ppConnData[lIndex]->SecondaryWINS));
  690. AddEditToArray(ptrarrayNew, iListItem++, _T(""), strTemp);
  691. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  692. AddEditToArray(ptrarrayNew, iListItem++, IDS_USE_IP_HEADER_COMPRESSION, GetStringFromVariant(ppConnData[lIndex]->IPHeaderCompression));
  693. AddEditToArray(ptrarrayNew, iListItem++, IDS_USE_DEFAULT_GATEWAY, GetStringFromVariant(ppConnData[lIndex]->DefaultGateway));
  694. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  695. AddEditToArray(ptrarrayNew, iListItem++, IDS_SCRIPT_FILE_NAME, GetStringFromVariant(ppConnData[lIndex]->ScriptFileName));
  696. }
  697. theApp.AppDeleteIEData(ConnSettingsType, lConnCount, (void**)ppConnData);
  698. }
  699. else
  700. {
  701. AddEditBlankLineToArray(ptrarrayNew, iListItem++);
  702. AddEditToArray(ptrarrayNew, iListItem++, IDS_NO_CONNECTIONS, _T(""));
  703. }
  704. }
  705. else if (iView == MSIVIEW_CACHE)
  706. {
  707. IE_CACHE **ppData;
  708. theApp.AppGetIEData(CacheType, &lCount, (void***)&ppData);
  709. if (lCount == 1)
  710. {
  711. AddToArray(ptrarrayNew, iListItem++, IDS_PAGE_REFRESH_TYPE, GetStringFromVariant((*ppData)->PageRefreshType));
  712. AddToArray(ptrarrayNew, iListItem++, IDS_TEMPORARY_INTERNET_FILES_FOLDER, GetStringFromVariant((*ppData)->TempInternetFilesFolder));
  713. AddToArray(ptrarrayNew, iListItem++, IDS_TOTAL_DISK_SPACE, GetStringFromVariant((*ppData)->TotalDiskSpace, IDS_FORMAT_MB));
  714. AddToArray(ptrarrayNew, iListItem++, IDS_AVAILABLE_DISK_SPACE, GetStringFromVariant((*ppData)->AvailableDiskSpace, IDS_FORMAT_MB));
  715. AddToArray(ptrarrayNew, iListItem++, IDS_MAX_CACHE_SIZE, GetStringFromVariant((*ppData)->MaxCacheSize, IDS_FORMAT_MB));
  716. AddToArray(ptrarrayNew, iListItem++, IDS_AVAILABLE_CACHE_SIZE, GetStringFromVariant((*ppData)->AvailableCacheSize, IDS_FORMAT_MB));
  717. }
  718. theApp.AppDeleteIEData(CacheType, lCount, (void**)ppData);
  719. }
  720. else if (iView == MSIVIEW_OBJECT_LIST)
  721. {
  722. IE_OBJECT **ppData;
  723. theApp.AppGetIEData(ObjectType, &lCount, (void***)&ppData);
  724. if (lCount > 0)
  725. {
  726. for (lIndex = 0; lIndex < lCount; lIndex++)
  727. {
  728. AddObjectToArray(ptrarrayNew, iListItem++,
  729. GetStringFromVariant(ppData[lIndex]->ProgramFile),
  730. GetStringFromVariant(ppData[lIndex]->Status),
  731. GetStringFromVariant(ppData[lIndex]->CodeBase));
  732. }
  733. theApp.AppDeleteIEData(ObjectType, lCount, (void**)ppData);
  734. }
  735. }
  736. else if (iView == MSIVIEW_CONTENT)
  737. {
  738. IE_CONTENT **ppData;
  739. theApp.AppGetIEData(ContentType, &lCount, (void***)&ppData);
  740. if (lCount == 1)
  741. {
  742. AddToArray(ptrarrayNew, iListItem++, IDS_CONTENT_ADVISOR, GetStringFromVariant((*ppData)->Advisor));
  743. }
  744. theApp.AppDeleteIEData(ContentType, lCount, (void**)ppData);
  745. }
  746. else if ((iView == MSIVIEW_PERSONAL_CERTIFICATES) || (iView == MSIVIEW_OTHER_PEOPLE_CERTIFICATES))
  747. {
  748. IE_CERTIFICATE **ppData;
  749. CString strType;
  750. int idsType;
  751. theApp.AppGetIEData(CertificateType, &lCount, (void***)&ppData);
  752. if (lCount > 0)
  753. {
  754. idsType = (iView == MSIVIEW_PERSONAL_CERTIFICATES)? IDS_PERSONAL_TYPE : IDS_OTHER_PEOPLE_TYPE;
  755. strType.LoadString(idsType);
  756. for (lIndex = 0; lIndex < lCount; lIndex++)
  757. {
  758. if (strType == ppData[lIndex]->Type.bstrVal)
  759. AddCertificateToArray(ptrarrayNew, iListItem++,
  760. GetStringFromVariant(ppData[lIndex]->IssuedTo),
  761. GetStringFromVariant(ppData[lIndex]->IssuedBy),
  762. GetStringFromVariant(ppData[lIndex]->Validity),
  763. GetStringFromVariant(ppData[lIndex]->SignatureAlgorithm));
  764. }
  765. theApp.AppDeleteIEData(CertificateType, lCount, (void**)ppData);
  766. }
  767. }
  768. else if (iView == MSIVIEW_PUBLISHERS)
  769. {
  770. IE_PUBLISHER **ppData;
  771. theApp.AppGetIEData(PublisherType, &lCount, (void***)&ppData);
  772. if (lCount > 0)
  773. {
  774. for (lIndex = 0; lIndex < lCount; lIndex++)
  775. {
  776. AddNameToArray(ptrarrayNew, iListItem++, GetStringFromVariant(ppData[lIndex]->Name));
  777. }
  778. theApp.AppDeleteIEData(PublisherType, lCount, (void**)ppData);
  779. }
  780. }
  781. else if (iView == MSIVIEW_SECURITY)
  782. {
  783. IE_SECURITY **ppData;
  784. theApp.AppGetIEData(SecurityType, &lCount, (void***)&ppData);
  785. if (lCount > 0)
  786. {
  787. for (lIndex = 0; lIndex < lCount; lIndex++)
  788. {
  789. AddToArray(ptrarrayNew, iListItem++, GetStringFromVariant(ppData[lIndex]->Zone), GetStringFromVariant(ppData[lIndex]->Level));
  790. }
  791. theApp.AppDeleteIEData(SecurityType, lCount, (void**)ppData);
  792. }
  793. }
  794. }
  795. CString CMsieCtrl::GetStringFromVariant(COleVariant &var, int idsFormat)
  796. {
  797. COleDateTime dateTime;
  798. CString strRet;
  799. switch (var.vt)
  800. {
  801. case VT_BSTR:
  802. strRet = var.bstrVal;
  803. break;
  804. case VT_I4:
  805. if (idsFormat)
  806. strRet.Format(idsFormat, var.lVal);
  807. else
  808. strRet.Format(_T("%d"), var.lVal);
  809. break;
  810. case VT_R4:
  811. if (idsFormat)
  812. strRet.Format(idsFormat, var.fltVal);
  813. else
  814. strRet.Format(_T("%0.1f"), var.fltVal);
  815. break;
  816. case VT_BOOL:
  817. strRet.LoadString(var.boolVal ? IDS_TRUE : IDS_FALSE);
  818. break;
  819. case VT_I2: // boolean
  820. strRet.LoadString(var.iVal ? IDS_TRUE : IDS_FALSE);
  821. break;
  822. case VT_DATE:
  823. dateTime = var.date;
  824. strRet = dateTime.Format();
  825. break;
  826. case VT_EMPTY:
  827. strRet.LoadString(IDS_NOT_AVAILABLE);
  828. break;
  829. default:
  830. ASSERT(false); // should be handling this type
  831. strRet.LoadString(IDS_NOT_AVAILABLE);
  832. }
  833. return strRet;
  834. }
  835. //-----------------------------------------------------------------------------
  836. // This helper method is called to add a list item to an array.
  837. //-----------------------------------------------------------------------------
  838. void CMsieCtrl::AddToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszItem, LPCTSTR pszValue)
  839. {
  840. LIST_ITEM *pListItem;
  841. if ((pListItem = new LIST_ITEM) == NULL)
  842. return;
  843. lstrcpyn(pListItem->szItem, pszItem, ITEM_LEN);
  844. lstrcpyn(pListItem->szValue, pszValue, VALUE_LEN);
  845. pListItem->uiView = m_uiView;
  846. ptrarray.SetAtGrow(itemNum, pListItem);
  847. }
  848. void CMsieCtrl::AddToArray(CPtrArray &ptrarray, int itemNum, int idsItem, LPCTSTR pszValue)
  849. {
  850. CString strItem;
  851. strItem.LoadString(idsItem);
  852. AddToArray(ptrarray, itemNum, strItem, pszValue);
  853. }
  854. void CMsieCtrl::AddFileVersionToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszFile, LPCTSTR pszVersion, LPCTSTR pszSize, LPCTSTR pszDate, LPCTSTR pszPath, LPCTSTR pszCompany, DWORD dwSize, DATE date)
  855. {
  856. LIST_FILE_VERSION *pFileVersion;
  857. if ((pFileVersion = new LIST_FILE_VERSION) == NULL)
  858. return;
  859. lstrcpyn(pFileVersion->szFile, pszFile, _MAX_FNAME);
  860. lstrcpyn(pFileVersion->szVersion, pszVersion, VERSION_LEN);
  861. lstrcpyn(pFileVersion->szSize, pszSize, SIZE_LEN);
  862. lstrcpyn(pFileVersion->szDate, pszDate, DATE_LEN);
  863. lstrcpyn(pFileVersion->szPath, pszPath, VALUE_LEN);
  864. lstrcpyn(pFileVersion->szCompany, pszCompany, VALUE_LEN);
  865. pFileVersion->uiView = m_uiView;
  866. pFileVersion->dwSize = dwSize;
  867. pFileVersion->date = date;
  868. ptrarray.SetAtGrow(itemNum, pFileVersion);
  869. }
  870. void CMsieCtrl::AddEditToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszItem, LPCTSTR pszValue, BOOL bBold)
  871. {
  872. EDIT_ITEM *pEditItem;
  873. if ((pEditItem = new EDIT_ITEM) == NULL)
  874. return;
  875. lstrcpyn(pEditItem->szItem, pszItem, ITEM_LEN);
  876. lstrcpyn(pEditItem->szValue, pszValue, VALUE_LEN);
  877. pEditItem->uiView = m_uiView;
  878. pEditItem->bBold = bBold;
  879. ptrarray.SetAtGrow(itemNum, pEditItem);
  880. }
  881. void CMsieCtrl::AddEditToArray(CPtrArray &ptrarray, int itemNum, int idsItem, LPCTSTR pszValue, BOOL bBold)
  882. {
  883. CString strItem;
  884. strItem.LoadString(idsItem);
  885. AddEditToArray(ptrarray, itemNum, strItem, pszValue, bBold);
  886. }
  887. void CMsieCtrl::AddObjectToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszProgramFile, LPCTSTR pszStatus, LPCTSTR pszCodeBase)
  888. {
  889. LIST_OBJECT *pObject;
  890. if ((pObject = new LIST_OBJECT) == NULL)
  891. return;
  892. lstrcpyn(pObject->szProgramFile, pszProgramFile, _MAX_FNAME);
  893. lstrcpyn(pObject->szStatus, pszStatus, STATUS_LEN);
  894. lstrcpyn(pObject->szCodeBase, pszCodeBase, MAX_PATH);
  895. pObject->uiView = m_uiView;
  896. ptrarray.SetAtGrow(itemNum, pObject);
  897. }
  898. void CMsieCtrl::AddCertificateToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszIssuedTo, LPCTSTR pszIssuedBy, LPCTSTR pszValidity, LPCTSTR pszSignatureAlgorithm)
  899. {
  900. LIST_CERT *pCert;
  901. if ((pCert = new LIST_CERT) == NULL)
  902. return;
  903. lstrcpyn(pCert->szIssuedTo, pszIssuedTo, _MAX_FNAME);
  904. lstrcpyn(pCert->szIssuedBy, pszIssuedBy, _MAX_FNAME);
  905. lstrcpyn(pCert->szValidity, pszValidity, _MAX_FNAME);
  906. lstrcpyn(pCert->szSignatureAlgorithm, pszSignatureAlgorithm, _MAX_FNAME);
  907. pCert->uiView = m_uiView;
  908. ptrarray.SetAtGrow(itemNum, pCert);
  909. }
  910. void CMsieCtrl::AddNameToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszName)
  911. {
  912. LIST_NAME *pName;
  913. if ((pName = new LIST_NAME) == NULL)
  914. return;
  915. lstrcpyn(pName->szName, pszName, _MAX_FNAME);
  916. pName->uiView = m_uiView;
  917. ptrarray.SetAtGrow(itemNum, pName);
  918. }
  919. //-----------------------------------------------------------------------------
  920. // This helper method is called to add a blank line list item to an array.
  921. //-----------------------------------------------------------------------------
  922. void CMsieCtrl::AddBlankLineToArray(CPtrArray &ptrarray, int itemNum)
  923. {
  924. AddToArray(ptrarray, itemNum, _T(""), _T(""));
  925. }
  926. void CMsieCtrl::AddEditBlankLineToArray(CPtrArray &ptrarray, int itemNum)
  927. {
  928. AddEditToArray(ptrarray, itemNum, _T(""), _T(""));
  929. }
  930. //-----------------------------------------------------------------------------
  931. // This method is called to update the display with the current data.
  932. //-----------------------------------------------------------------------------
  933. void CMsieCtrl::MSInfoUpdateView()
  934. {
  935. TRACE0("-- CMsieCtrl::MSInfoUpdateView()\n");
  936. if (m_MSInfoView == MSIVIEW_CONNECTIVITY)
  937. {
  938. if (!m_edit.IsWindowVisible())
  939. {
  940. m_list.ShowWindow(SW_HIDE);
  941. m_list.EnableWindow(FALSE);
  942. m_static.ShowWindow(SW_SHOW);
  943. m_btnBasic.ShowWindow(SW_SHOW);
  944. m_btnBasic.EnableWindow(TRUE);
  945. m_btnAdvanced.ShowWindow(SW_SHOW);
  946. m_btnAdvanced.EnableWindow(TRUE);
  947. m_edit.ShowWindow(SW_SHOW);
  948. m_edit.EnableWindow(TRUE);
  949. }
  950. RefreshEditControl(TRUE);
  951. }
  952. else
  953. {
  954. if (!m_list.IsWindowVisible())
  955. {
  956. m_static.ShowWindow(SW_HIDE);
  957. m_btnBasic.ShowWindow(SW_HIDE);
  958. m_btnBasic.EnableWindow(FALSE);
  959. m_btnAdvanced.ShowWindow(SW_HIDE);
  960. m_btnAdvanced.EnableWindow(FALSE);
  961. m_edit.ShowWindow(SW_HIDE);
  962. m_edit.EnableWindow(FALSE);
  963. m_list.ShowWindow(SW_SHOW);
  964. m_list.EnableWindow(TRUE);
  965. }
  966. RefreshListControl(TRUE);
  967. }
  968. }
  969. //-----------------------------------------------------------------------------
  970. // This method updates the list control to contain the contents of the
  971. // pointer array. This is also where we compute some of the values used in
  972. // sizing the columns (like minimum and maximum column widths). Remember, only
  973. // put the item in the list view if the MSInfoView index and the flag for
  974. // the item agree.
  975. //
  976. // For each line we add, we set the item data for that line to be the index
  977. // to the element in the pointer array for that item. Since more than one
  978. // line comes from each element in the array, we OR in a constant.
  979. //-----------------------------------------------------------------------------
  980. void CMsieCtrl::RefreshListControl(BOOL bRedraw)
  981. {
  982. TRACE0("-- CMsieCtrl::RefreshListControl()\n");
  983. LIST_ITEM *pListItem;
  984. LIST_FILE_VERSION *pFileVersion;
  985. LIST_OBJECT *pObject;
  986. LIST_CERT *pCert;
  987. LIST_NAME *pName;
  988. CRect rect;
  989. int listIndex = 0;
  990. m_list.SetRedraw(FALSE);
  991. m_list.DeleteAllItems();
  992. // Format columns adds the appropriate columns to the list control.
  993. FormatColumns();
  994. for (int itemNum = 0; itemNum < m_ptrarray.GetSize(); itemNum++)
  995. {
  996. pListItem = (LIST_ITEM *)m_ptrarray.GetAt(itemNum);
  997. if (pListItem)
  998. {
  999. if ((long)pListItem->uiView == m_MSInfoView)
  1000. {
  1001. if (pListItem->uiView == MSIVIEW_FILE_VERSIONS)
  1002. {
  1003. pFileVersion = (LIST_FILE_VERSION *)pListItem;
  1004. AddItem(listIndex, 0, pFileVersion->szFile);
  1005. AddItem(listIndex, 1, pFileVersion->szVersion);
  1006. AddItem(listIndex, 2, pFileVersion->szSize);
  1007. AddItem(listIndex, 3, pFileVersion->szDate);
  1008. AddItem(listIndex, 4, pFileVersion->szPath);
  1009. AddItem(listIndex, 5, pFileVersion->szCompany);
  1010. }
  1011. else if (pListItem->uiView == MSIVIEW_OBJECT_LIST)
  1012. {
  1013. pObject = (LIST_OBJECT *)pListItem;
  1014. AddItem(listIndex, 0, pObject->szProgramFile);
  1015. AddItem(listIndex, 1, pObject->szStatus);
  1016. AddItem(listIndex, 2, pObject->szCodeBase);
  1017. }
  1018. else if ((pListItem->uiView == MSIVIEW_PERSONAL_CERTIFICATES) || (pListItem->uiView == MSIVIEW_OTHER_PEOPLE_CERTIFICATES))
  1019. {
  1020. pCert = (LIST_CERT *)pListItem;
  1021. AddItem(listIndex, 0, pCert->szIssuedTo);
  1022. AddItem(listIndex, 1, pCert->szIssuedBy);
  1023. AddItem(listIndex, 2, pCert->szValidity);
  1024. AddItem(listIndex, 3, pCert->szSignatureAlgorithm);
  1025. }
  1026. else if (pListItem->uiView == MSIVIEW_PUBLISHERS)
  1027. {
  1028. pName = (LIST_NAME *)pListItem;
  1029. AddItem(listIndex, 0, pName->szName);
  1030. }
  1031. else
  1032. {
  1033. AddItem(listIndex, 0, pListItem->szItem);
  1034. AddItem(listIndex, 1, pListItem->szValue);
  1035. }
  1036. m_list.SetItemData(listIndex, itemNum);
  1037. listIndex++;
  1038. }
  1039. }
  1040. }
  1041. // Now, figure some values for the column widths. But only if we actually added
  1042. // items to the list.
  1043. if (listIndex)
  1044. {
  1045. int cxMax, cxWidth, cxMin, cxAverage;
  1046. for (int iCol = 0; iCol < m_cColumns; iCol++)
  1047. {
  1048. cxMax = 0; cxMin = 0; cxAverage = 0;
  1049. for (int iRow = 0; iRow < m_list.GetItemCount(); iRow++)
  1050. {
  1051. cxWidth = m_list.GetStringWidth(m_list.GetItemText(iRow, iCol));
  1052. if (cxWidth > cxMax)
  1053. cxMax = cxWidth;
  1054. if ((cxWidth < cxMin || cxMin == 0) && cxWidth != 0)
  1055. cxMin = cxWidth;
  1056. cxAverage += cxWidth;
  1057. }
  1058. cxAverage /= m_list.GetItemCount();
  1059. m_aiMaxWidths[iCol] = cxMax + 12;
  1060. m_aiMinWidths[iCol] = cxAverage + 12;
  1061. }
  1062. }
  1063. GetClientRect(&rect);
  1064. RefigureColumns(rect);
  1065. m_list.SetRedraw(TRUE);
  1066. if (bRedraw)
  1067. InvalidateControl();
  1068. }
  1069. void CMsieCtrl::RefreshEditControl(BOOL bRedraw)
  1070. {
  1071. TRACE0("-- CMsieCtrl::RefreshEditControl()\n");
  1072. EDIT_ITEM *pEditItem;
  1073. CString strLine;
  1074. CHARFORMAT cf;
  1075. SIZE sizeSpace, sizeStr;
  1076. int itemNum, nLen, i, cLines = 0;
  1077. BOOL bBasicView;
  1078. DrawLine();
  1079. m_edit.SetRedraw(FALSE);
  1080. m_edit.SetWindowText(_T(""));
  1081. bBasicView = m_btnBasic.GetCheck();
  1082. cf.cbSize = sizeof(cf);
  1083. cf.dwMask = CFM_BOLD;
  1084. GetTextExtentPoint(m_edit.GetDC()->m_hDC, _T(" "), 1, &sizeSpace);
  1085. for (itemNum = 0; itemNum < m_ptrarray.GetSize(); itemNum++)
  1086. {
  1087. pEditItem = (EDIT_ITEM *)m_ptrarray.GetAt(itemNum);
  1088. if (pEditItem)
  1089. {
  1090. if ((long)pEditItem->uiView == m_MSInfoView)
  1091. {
  1092. strLine = _T(" ");
  1093. if (!pEditItem->bBold)
  1094. strLine += _T(' ');
  1095. strLine += pEditItem->szItem;
  1096. if (pEditItem->szValue[0] != _T('\0'))
  1097. {
  1098. GetTextExtentPoint(m_edit.GetDC()->m_hDC, pEditItem->szItem, _tcslen(pEditItem->szItem), &sizeStr);
  1099. nLen = sizeStr.cx / sizeSpace.cx;
  1100. if (nLen < 50)
  1101. {
  1102. for (i = nLen; i < 50; i++)
  1103. strLine += _T(' ');
  1104. }
  1105. strLine += _T('\t');
  1106. strLine += pEditItem->szValue;
  1107. }
  1108. strLine += _T('\n');
  1109. m_edit.SetSel(-1, -1);
  1110. cf.dwEffects = pEditItem->bBold ? CFE_BOLD : 0;
  1111. m_edit.SetSelectionCharFormat(cf);
  1112. m_edit.ReplaceSel(strLine);
  1113. // only show default connection info if basic info button checked
  1114. if (bBasicView)
  1115. if (++cLines == CONNECTIVITY_BASIC_LINES)
  1116. break;
  1117. }
  1118. }
  1119. }
  1120. m_edit.SetRedraw(TRUE);
  1121. if (bRedraw)
  1122. InvalidateControl();
  1123. }
  1124. //-----------------------------------------------------------------------------
  1125. // MSInfo Specific...
  1126. //
  1127. // When the control is resized, we want to also resize the list
  1128. // control. We'll also call a method to resize the columns in the
  1129. // list control, based on the new control size.
  1130. //-----------------------------------------------------------------------------
  1131. void CMsieCtrl::OnSize(UINT nType, int cx, int cy)
  1132. {
  1133. COleControl::OnSize(nType, cx, cy);
  1134. CRect rect;
  1135. GetClientRect(&rect);
  1136. m_edit.MoveWindow(CRect(rect.left, rect.top + 63, rect.right, rect.bottom));
  1137. m_list.MoveWindow(&rect);
  1138. if (m_MSInfoView == MSIVIEW_CONNECTIVITY)
  1139. {
  1140. m_edit.Invalidate();
  1141. }
  1142. else
  1143. {
  1144. RefigureColumns(rect);
  1145. m_list.Invalidate();
  1146. }
  1147. }
  1148. //-----------------------------------------------------------------------------
  1149. // MSInfo Specific...
  1150. //
  1151. // The Serialize method is used to save the state of your object to
  1152. // a stream, or to load it from a stream. This stream is part of the
  1153. // compound MSInfo file. Your control can also open a file directly
  1154. // by making an entry in the MSInfo registry key indicating what
  1155. // file types it can open. In that case, the file will be passed to
  1156. // MSInfoLoadFile.
  1157. //
  1158. // The InternetExplorer category will save the items in it's list view to the
  1159. // archive as a struct. The first item in the archive will be a DWORD
  1160. // indicating how many pairs will be saved. The view for each struct will be
  1161. // archived out just before the struct for easier loading (knowing which type
  1162. // of struct to new for loading).
  1163. //-----------------------------------------------------------------------------
  1164. void CMsieCtrl::Serialize(CArchive& ar)
  1165. {
  1166. TRACE1("-- CMsieCtrl::Serialize() [%s]\n", (ar.IsStoring()) ? "STORE" : "LOAD");
  1167. LIST_ITEM *pListItem;
  1168. LIST_FILE_VERSION *pFileVersion;
  1169. LIST_OBJECT *pObject;
  1170. LIST_CERT *pCert;
  1171. LIST_NAME *pName;
  1172. EDIT_ITEM *pEditItem;
  1173. DWORD dwCount;
  1174. UINT uiView;
  1175. if (ar.IsStoring())
  1176. {
  1177. dwCount = (DWORD) m_ptrarray.GetSize();
  1178. ar << dwCount;
  1179. for (DWORD i = 0; i < dwCount; i++)
  1180. {
  1181. pListItem = (LIST_ITEM *)m_ptrarray.GetAt(i);
  1182. if (pListItem)
  1183. {
  1184. ar << pListItem->uiView;
  1185. switch (pListItem->uiView)
  1186. {
  1187. case MSIVIEW_FILE_VERSIONS:
  1188. pFileVersion = (LIST_FILE_VERSION *)pListItem;
  1189. ar.Write((void *)pFileVersion, sizeof(LIST_FILE_VERSION));
  1190. break;
  1191. case MSIVIEW_OBJECT_LIST:
  1192. pObject = (LIST_OBJECT *)pListItem;
  1193. ar.Write((void *)pObject, sizeof(LIST_OBJECT));
  1194. break;
  1195. case MSIVIEW_CONNECTIVITY:
  1196. pEditItem = (EDIT_ITEM *)pListItem;
  1197. ar.Write((void *)pEditItem, sizeof(EDIT_ITEM));
  1198. break;
  1199. case MSIVIEW_PERSONAL_CERTIFICATES:
  1200. case MSIVIEW_OTHER_PEOPLE_CERTIFICATES:
  1201. pCert = (LIST_CERT *)pListItem;
  1202. ar.Write((void *)pCert, sizeof(LIST_CERT));
  1203. break;
  1204. case MSIVIEW_PUBLISHERS:
  1205. pName = (LIST_NAME *)pListItem;
  1206. ar.Write((void *)pName, sizeof(LIST_NAME));
  1207. break;
  1208. default:
  1209. ar.Write((void *)pListItem, sizeof(LIST_ITEM));
  1210. }
  1211. }
  1212. }
  1213. }
  1214. else
  1215. {
  1216. ar >> dwCount;
  1217. for (DWORD i = 0; i < dwCount; i++)
  1218. {
  1219. ar >> uiView;
  1220. switch (uiView)
  1221. {
  1222. case MSIVIEW_FILE_VERSIONS:
  1223. pFileVersion = new LIST_FILE_VERSION;
  1224. if (pFileVersion)
  1225. {
  1226. if (ar.Read((void *)pFileVersion, sizeof(LIST_FILE_VERSION)) != sizeof(LIST_FILE_VERSION))
  1227. break;
  1228. m_ptrarray.SetAtGrow(i, pFileVersion);
  1229. }
  1230. break;
  1231. case MSIVIEW_OBJECT_LIST:
  1232. pObject = new LIST_OBJECT;
  1233. if (pObject)
  1234. {
  1235. if (ar.Read((void *)pObject, sizeof(LIST_OBJECT)) != sizeof(LIST_OBJECT))
  1236. break;
  1237. m_ptrarray.SetAtGrow(i, pObject);
  1238. }
  1239. break;
  1240. case MSIVIEW_CONNECTIVITY:
  1241. pEditItem = new EDIT_ITEM;
  1242. if (pEditItem)
  1243. {
  1244. if (ar.Read((void *)pEditItem, sizeof(EDIT_ITEM)) != sizeof(EDIT_ITEM))
  1245. break;
  1246. m_ptrarray.SetAtGrow(i, pEditItem);
  1247. }
  1248. break;
  1249. case MSIVIEW_PERSONAL_CERTIFICATES:
  1250. case MSIVIEW_OTHER_PEOPLE_CERTIFICATES:
  1251. pCert = new LIST_CERT;
  1252. if (pCert)
  1253. {
  1254. if (ar.Read((void *)pCert, sizeof(LIST_CERT)) != sizeof(LIST_CERT))
  1255. break;
  1256. m_ptrarray.SetAtGrow(i, pCert);
  1257. }
  1258. break;
  1259. case MSIVIEW_PUBLISHERS:
  1260. pName = new LIST_NAME;
  1261. if (pName)
  1262. {
  1263. if (ar.Read((void *)pName, sizeof(LIST_NAME)) != sizeof(LIST_NAME))
  1264. break;
  1265. m_ptrarray.SetAtGrow(i, pName);
  1266. }
  1267. break;
  1268. default:
  1269. pListItem = new LIST_ITEM;
  1270. if (pListItem)
  1271. {
  1272. if (ar.Read((void *)pListItem, sizeof(LIST_ITEM)) != sizeof(LIST_ITEM))
  1273. break;
  1274. m_ptrarray.SetAtGrow(i, pListItem);
  1275. }
  1276. }
  1277. }
  1278. m_bCurrent = false;
  1279. }
  1280. }
  1281. //-----------------------------------------------------------------------------
  1282. // MSInfo Specific...
  1283. //
  1284. // A control used in MSInfo has the ability to register itself as
  1285. // recognizing a file type (by extension). This entry is made in the
  1286. // registry, and when MSInfo lets the user open a file, files of this
  1287. // type can be displayed. If a file is chosen, a different set of
  1288. // categories is loaded, presumably all using this control. When
  1289. // the control is created, a call will be made to MSInfoLoadFile with
  1290. // the file to load.
  1291. //
  1292. // There isn't a native file format for this control, so we do
  1293. // exactly nothing.
  1294. //-----------------------------------------------------------------------------
  1295. BOOL CMsieCtrl::MSInfoLoadFile(LPCTSTR szFileName)
  1296. {
  1297. TRACE1("-- CMsieCtrl::MSInfoLoadFile(%s)\n", szFileName);
  1298. return TRUE;
  1299. }
  1300. //-----------------------------------------------------------------------------
  1301. // MSInfo Specific...
  1302. //
  1303. // This method should do a select all on the information the control
  1304. // shows. This only applies to controls which support selection.
  1305. // If the selection is changed, the control is responsible for
  1306. // redrawing itself
  1307. //
  1308. // For this control, we mark all of the items in the list view as selected.
  1309. //-----------------------------------------------------------------------------
  1310. void CMsieCtrl::MSInfoSelectAll()
  1311. {
  1312. TRACE0("-- CMsieCtrl::SelectAll()\n");
  1313. if (m_MSInfoView == MSIVIEW_CONNECTIVITY)
  1314. {
  1315. m_edit.SetFocus();
  1316. m_edit.SetSel(0, -1);
  1317. }
  1318. else
  1319. {
  1320. m_list.SetFocus();
  1321. for (int i = 0; i < m_list.GetItemCount(); i++)
  1322. m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  1323. }
  1324. InvalidateControl();
  1325. }
  1326. //-----------------------------------------------------------------------------
  1327. // MSInfo Specific...
  1328. //
  1329. // Use this method to copy the currently selected information into
  1330. // the clipboard in an appropriate format. If your control does not
  1331. // support user selection, then all of the data displayed by your
  1332. // control should be put into the clipboard. If this is the case,
  1333. // only the information shown by the current MSInfoView should be
  1334. // copied (if you support multiple views).
  1335. //
  1336. // We'll scan through the list view, and generate a text string
  1337. // containing the text from each selected line.
  1338. //-----------------------------------------------------------------------------
  1339. void CMsieCtrl::MSInfoCopy()
  1340. {
  1341. TRACE0("-- CMsieCtrl::MSInfoCopy()\n");
  1342. CString strReturnText;
  1343. int i, nIndex;
  1344. // Build a string of the text of selected items.
  1345. if (m_MSInfoView == MSIVIEW_CONNECTIVITY)
  1346. {
  1347. strReturnText = m_edit.GetSelText();
  1348. }
  1349. else
  1350. {
  1351. for (i = 0; i < m_list.GetItemCount(); i++)
  1352. {
  1353. if (m_list.GetItemState(i, LVIS_SELECTED) != 0)
  1354. {
  1355. strReturnText += m_list.GetItemText(i, 0);
  1356. for (nIndex = 1; nIndex < m_cColumns; nIndex++)
  1357. {
  1358. strReturnText += '\t';
  1359. strReturnText += m_list.GetItemText(i, nIndex);
  1360. }
  1361. strReturnText += CString("\r\n");
  1362. }
  1363. }
  1364. }
  1365. // Put that text in the clipboard.
  1366. if (OpenClipboard())
  1367. {
  1368. if (EmptyClipboard())
  1369. {
  1370. DWORD dwSize = strReturnText.GetLength() + 1; // +1 for terminating NULL
  1371. HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, dwSize);
  1372. if (hMem)
  1373. {
  1374. LPVOID lpvoid = GlobalLock(hMem);
  1375. if (lpvoid)
  1376. {
  1377. memcpy(lpvoid, (LPCTSTR) strReturnText, dwSize);
  1378. GlobalUnlock(hMem);
  1379. SetClipboardData(CF_TEXT, hMem);
  1380. }
  1381. }
  1382. }
  1383. CloseClipboard();
  1384. }
  1385. }
  1386. //-----------------------------------------------------------------------------
  1387. // MSInfo Specific...
  1388. //
  1389. // The control should return its contents as text when this method
  1390. // is called. The parameters are a pointer to a buffer and a length
  1391. // of the buffer in bytes. Write the contents of the control to the
  1392. // buffer (including a null) up to dwLength. Return the number of
  1393. // bytes copied (not including the null). If the pointer parameter is
  1394. // null, then just return the length.
  1395. //
  1396. // For this example, we get the text from the list and concatenate
  1397. // the columns together.
  1398. //-----------------------------------------------------------------------------
  1399. static CString strGetDataReturnText;
  1400. long CMsieCtrl::MSInfoGetData(long dwMSInfoView, long FAR* pBuffer, long dwLength)
  1401. {
  1402. TRACE2("-- CMsieCtrl::MSInfoGetData(0x%08x, %ld)\n", (long) pBuffer, dwLength);
  1403. LIST_ITEM * pListItem;
  1404. LIST_FILE_VERSION *pFileVersion;
  1405. LIST_OBJECT *pObject;
  1406. LIST_CERT *pCert;
  1407. LIST_NAME *pName;
  1408. CString strWorking, strTemp;
  1409. if (pBuffer == NULL)
  1410. {
  1411. // We should get the data from the array of pointers, not the list
  1412. // control. This is because this method might be called without
  1413. // ever drawing the list. We need to use the current MSInfoView
  1414. // in determining what to return.
  1415. strGetDataReturnText.Empty();
  1416. // write out column headers if view with columns
  1417. switch (dwMSInfoView)
  1418. {
  1419. case MSIVIEW_FILE_VERSIONS:
  1420. strTemp.LoadString(IDS_FILE);
  1421. strGetDataReturnText += strTemp;
  1422. strGetDataReturnText += '\t';
  1423. strTemp.LoadString(IDS_VERSION);
  1424. strGetDataReturnText += strTemp;
  1425. strGetDataReturnText += '\t';
  1426. strTemp.LoadString(IDS_SIZE);
  1427. strGetDataReturnText += strTemp;
  1428. strGetDataReturnText += '\t';
  1429. strTemp.LoadString(IDS_DATE);
  1430. strGetDataReturnText += strTemp;
  1431. strGetDataReturnText += '\t';
  1432. strTemp.LoadString(IDS_PATH);
  1433. strGetDataReturnText += strTemp;
  1434. strGetDataReturnText += '\t';
  1435. strTemp.LoadString(IDS_COMPANY);
  1436. strGetDataReturnText += strTemp;
  1437. break;
  1438. case MSIVIEW_OBJECT_LIST:
  1439. strTemp.LoadString(IDS_PROGRAM_FILE);
  1440. strGetDataReturnText += strTemp;
  1441. strGetDataReturnText += '\t';
  1442. strTemp.LoadString(IDS_STATUS);
  1443. strGetDataReturnText += strTemp;
  1444. strGetDataReturnText += '\t';
  1445. strTemp.LoadString(IDS_CODE_BASE);
  1446. strGetDataReturnText += strTemp;
  1447. break;
  1448. case MSIVIEW_PERSONAL_CERTIFICATES:
  1449. case MSIVIEW_OTHER_PEOPLE_CERTIFICATES:
  1450. break;
  1451. // BUGBUG: NEED TO FILL IN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1452. case MSIVIEW_PUBLISHERS:
  1453. break;
  1454. // BUGBUG: NEED TO FILL IN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1455. break;
  1456. }
  1457. for (int i = 0; i < m_ptrarray.GetSize(); i++)
  1458. {
  1459. pListItem = (LIST_ITEM *) m_ptrarray.GetAt(i);
  1460. if (pListItem != NULL)
  1461. {
  1462. if ((long)pListItem->uiView == dwMSInfoView)
  1463. {
  1464. strWorking.Empty();
  1465. switch (dwMSInfoView)
  1466. {
  1467. case MSIVIEW_FILE_VERSIONS:
  1468. pFileVersion = (LIST_FILE_VERSION *)pListItem;
  1469. if (pFileVersion->szFile[0] != _T('\0'))
  1470. {
  1471. strWorking += pFileVersion->szFile;
  1472. strWorking += '\t';
  1473. strWorking += pFileVersion->szVersion;
  1474. strWorking += '\t';
  1475. strWorking += pFileVersion->szSize;
  1476. strWorking += '\t';
  1477. strWorking += pFileVersion->szDate;
  1478. strWorking += '\t';
  1479. strWorking += pFileVersion->szPath;
  1480. strWorking += '\t';
  1481. strWorking += pFileVersion->szCompany;
  1482. }
  1483. break;
  1484. case MSIVIEW_OBJECT_LIST:
  1485. pObject = (LIST_OBJECT *)pListItem;
  1486. if (pObject->szProgramFile[0] != _T('\0'))
  1487. {
  1488. strWorking += pObject->szProgramFile;
  1489. strWorking += '\t';
  1490. strWorking += pObject->szStatus;
  1491. strWorking += '\t';
  1492. strWorking += pObject->szCodeBase;
  1493. }
  1494. break;
  1495. case MSIVIEW_PERSONAL_CERTIFICATES:
  1496. case MSIVIEW_OTHER_PEOPLE_CERTIFICATES:
  1497. pCert = (LIST_CERT *)pListItem;
  1498. if (pCert->szIssuedTo[0] != _T('\0'))
  1499. {
  1500. strWorking += pCert->szIssuedTo;
  1501. strWorking += '\t';
  1502. strWorking += pCert->szIssuedBy;
  1503. strWorking += '\t';
  1504. strWorking += pCert->szValidity;
  1505. strWorking += '\t';
  1506. strWorking += pCert->szSignatureAlgorithm;
  1507. }
  1508. break;
  1509. case MSIVIEW_PUBLISHERS:
  1510. pName = (LIST_NAME *)pListItem;
  1511. if (pName->szName[0] != _T('\0'))
  1512. {
  1513. strWorking += pName->szName;
  1514. }
  1515. break;
  1516. default:
  1517. strWorking += pListItem->szItem;
  1518. strWorking += '\t';
  1519. strWorking += pListItem->szValue;
  1520. }
  1521. strWorking.TrimRight();
  1522. if (!strGetDataReturnText.IsEmpty())
  1523. strGetDataReturnText += _T("\r\n");
  1524. strGetDataReturnText += strWorking;
  1525. }
  1526. }
  1527. }
  1528. return (long) strGetDataReturnText.GetLength();
  1529. }
  1530. else
  1531. {
  1532. DWORD dwSize;
  1533. // dwSize will be the number of characters to copy, and shouldn't
  1534. // include the null terminator.
  1535. dwSize = strGetDataReturnText.GetLength();
  1536. if (dwLength <= (long)dwSize)
  1537. {
  1538. // There isn't enough room in the buffer to copy all of the
  1539. // characters and the null, so we'll need to concatenate.
  1540. dwSize = dwLength - 1;
  1541. }
  1542. memcpy(pBuffer, (LPCTSTR) strGetDataReturnText, dwSize);
  1543. ((char *)pBuffer)[dwSize] = '\0';
  1544. return (long) dwSize;
  1545. }
  1546. }
  1547. //-----------------------------------------------------------------------------
  1548. // We override the OnNotify member because we want to be able to take action
  1549. // when the user resizes a column (possibly by double clicking the divider)
  1550. // and when the user clicks on a column header (we want to sort by that
  1551. // column).
  1552. //-----------------------------------------------------------------------------
  1553. CPtrArray* pptrarray;
  1554. static bool bAscendingOrder = true;
  1555. static int nLastColumn = 0;
  1556. int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
  1557. BOOL CMsieCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  1558. {
  1559. NMHDR *pnmhdr = (NMHDR *)lParam;
  1560. NM_LISTVIEW *pnmlv;
  1561. if (pnmhdr)
  1562. {
  1563. if (pnmhdr->code == HDN_ENDTRACK || pnmhdr->code == HDN_DIVIDERDBLCLICK)
  1564. RefigureColumns(CRect(0,0,0,0));
  1565. if (wParam == IDC_LISTCTRL)
  1566. {
  1567. switch (pnmhdr->code)
  1568. {
  1569. case LVN_COLUMNCLICK:
  1570. if ((m_MSInfoView == MSIVIEW_FILE_VERSIONS) ||
  1571. (m_MSInfoView == MSIVIEW_OBJECT_LIST) ||
  1572. (m_MSInfoView == MSIVIEW_PERSONAL_CERTIFICATES) ||
  1573. (m_MSInfoView == MSIVIEW_OTHER_PEOPLE_CERTIFICATES) ||
  1574. (m_MSInfoView == MSIVIEW_PUBLISHERS))
  1575. {
  1576. pnmlv = (NM_LISTVIEW*)lParam;
  1577. pptrarray = &m_ptrarray;
  1578. if (nLastColumn == pnmlv->iSubItem)
  1579. {
  1580. bAscendingOrder = !bAscendingOrder;
  1581. }
  1582. else
  1583. {
  1584. bAscendingOrder = true;
  1585. nLastColumn = pnmlv->iSubItem;
  1586. }
  1587. m_list.SortItems(CompareFunc, (LPARAM)pnmlv->iSubItem);
  1588. }
  1589. break;
  1590. }
  1591. }
  1592. }
  1593. return COleControl::OnNotify(wParam, lParam, pResult);
  1594. }
  1595. //-----------------------------------------------------------------------------
  1596. // This compare function is called by the list control as a callback when we
  1597. // sort the list.
  1598. //-----------------------------------------------------------------------------
  1599. int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  1600. {
  1601. int nRet = 0;
  1602. double flDateDiff;
  1603. // lParamSort contains a pointer to the list view control.
  1604. // The lParam of an item is just its index.
  1605. LIST_ITEM *pItem = (LIST_ITEM *)pptrarray->GetAt(lParam1);
  1606. if (pItem->uiView == MSIVIEW_FILE_VERSIONS)
  1607. {
  1608. LIST_FILE_VERSION* pItem1 = (LIST_FILE_VERSION *)pptrarray->GetAt(lParam1);
  1609. LIST_FILE_VERSION* pItem2 = (LIST_FILE_VERSION *)pptrarray->GetAt(lParam2);
  1610. ASSERT(pItem1 != NULL && pItem2 != NULL);
  1611. if (pItem1 == NULL || pItem2 == NULL)
  1612. return 0;
  1613. switch (lParamSort)
  1614. {
  1615. case 0:
  1616. nRet = _tcsicmp(pItem1->szFile, pItem2->szFile);
  1617. break;
  1618. case 1:
  1619. nRet = _tcsicmp(pItem2->szVersion, pItem1->szVersion);
  1620. break;
  1621. case 2:
  1622. nRet = pItem1->dwSize - pItem2->dwSize;
  1623. break;
  1624. case 3:
  1625. flDateDiff = pItem1->date - pItem2->date;
  1626. if (flDateDiff > 0)
  1627. nRet = -1;
  1628. else if (flDateDiff < 0)
  1629. nRet = 1;
  1630. break;
  1631. case 4:
  1632. nRet = _tcsicmp(pItem1->szPath, pItem2->szPath);
  1633. break;
  1634. case 5:
  1635. nRet = _tcsicmp(pItem1->szCompany, pItem2->szCompany);
  1636. break;
  1637. }
  1638. }
  1639. else if (pItem->uiView == MSIVIEW_OBJECT_LIST)
  1640. {
  1641. LIST_OBJECT* pItem1 = (LIST_OBJECT *)pptrarray->GetAt(lParam1);
  1642. LIST_OBJECT* pItem2 = (LIST_OBJECT *)pptrarray->GetAt(lParam2);
  1643. ASSERT(pItem1 != NULL && pItem2 != NULL);
  1644. if (pItem1 == NULL || pItem2 == NULL)
  1645. return 0;
  1646. switch (lParamSort)
  1647. {
  1648. case 0:
  1649. nRet = _tcsicmp(pItem1->szProgramFile, pItem2->szProgramFile);
  1650. break;
  1651. case 1:
  1652. nRet = _tcsicmp(pItem1->szStatus, pItem2->szStatus);
  1653. break;
  1654. case 2:
  1655. nRet = _tcsicmp(pItem1->szCodeBase, pItem2->szCodeBase);
  1656. break;
  1657. }
  1658. }
  1659. else if ((pItem->uiView == MSIVIEW_PERSONAL_CERTIFICATES) || (pItem->uiView == MSIVIEW_OTHER_PEOPLE_CERTIFICATES))
  1660. {
  1661. LIST_CERT* pItem1 = (LIST_CERT *)pptrarray->GetAt(lParam1);
  1662. LIST_CERT* pItem2 = (LIST_CERT *)pptrarray->GetAt(lParam2);
  1663. ASSERT(pItem1 != NULL && pItem2 != NULL);
  1664. if (pItem1 == NULL || pItem2 == NULL)
  1665. return 0;
  1666. switch (lParamSort)
  1667. {
  1668. case 0:
  1669. nRet = _tcsicmp(pItem1->szIssuedTo, pItem2->szIssuedTo);
  1670. break;
  1671. case 1:
  1672. nRet = _tcsicmp(pItem1->szIssuedBy, pItem2->szIssuedBy);
  1673. break;
  1674. case 2:
  1675. nRet = _tcsicmp(pItem1->szValidity, pItem2->szValidity);
  1676. break;
  1677. case 3:
  1678. nRet = _tcsicmp(pItem1->szSignatureAlgorithm, pItem2->szSignatureAlgorithm);
  1679. break;
  1680. }
  1681. }
  1682. else if (pItem->uiView == MSIVIEW_PUBLISHERS)
  1683. {
  1684. LIST_NAME* pItem1 = (LIST_NAME *)pptrarray->GetAt(lParam1);
  1685. LIST_NAME* pItem2 = (LIST_NAME *)pptrarray->GetAt(lParam2);
  1686. ASSERT(pItem1 != NULL && pItem2 != NULL);
  1687. if (pItem1 == NULL || pItem2 == NULL)
  1688. return 0;
  1689. switch (lParamSort)
  1690. {
  1691. case 0:
  1692. nRet = _tcsicmp(pItem1->szName, pItem2->szName);
  1693. break;
  1694. }
  1695. }
  1696. if (!bAscendingOrder)
  1697. nRet = -nRet;
  1698. return nRet;
  1699. }
  1700. HBRUSH CMsieCtrl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  1701. {
  1702. switch (nCtlColor)
  1703. {
  1704. case CTLCOLOR_STATIC:
  1705. case CTLCOLOR_BTN:
  1706. return (HBRUSH)(m_pCtlBkBrush->GetSafeHandle());
  1707. default:
  1708. return CWnd::OnCtlColor(pDC, pWnd, nCtlColor);
  1709. }
  1710. }
  1711. void CMsieCtrl::OnBasicBtnClicked()
  1712. {
  1713. MSInfoUpdateView();
  1714. }
  1715. void CMsieCtrl::OnAdvancedBtnClicked()
  1716. {
  1717. MSInfoUpdateView();
  1718. }
  1719. /////////////////////////////////////////////////////////////////////////////
  1720. // CMsieCtrl::XWbemProviderInit
  1721. STDMETHODIMP_(ULONG) CMsieCtrl::XWbemProviderInit::AddRef()
  1722. {
  1723. METHOD_PROLOGUE(CMsieCtrl, WbemProviderInit)
  1724. return pThis->ExternalAddRef();
  1725. }
  1726. STDMETHODIMP_(ULONG) CMsieCtrl::XWbemProviderInit::Release()
  1727. {
  1728. METHOD_PROLOGUE(CMsieCtrl, WbemProviderInit)
  1729. return pThis->ExternalRelease();
  1730. }
  1731. STDMETHODIMP CMsieCtrl::XWbemProviderInit::QueryInterface(REFIID iid, LPVOID* ppvObj)
  1732. {
  1733. METHOD_PROLOGUE(CMsieCtrl, WbemProviderInit)
  1734. return pThis->ExternalQueryInterface(&iid, ppvObj);
  1735. }
  1736. STDMETHODIMP CMsieCtrl::XWbemProviderInit::Initialize(LPWSTR pszUser, LONG lFlags,
  1737. LPWSTR pszNamespace, LPWSTR pszLocale,
  1738. IWbemServices *pNamespace,
  1739. IWbemContext *pCtx,
  1740. IWbemProviderInitSink *pInitSink)
  1741. {
  1742. METHOD_PROLOGUE(CMsieCtrl, WbemProviderInit)
  1743. if (pNamespace)
  1744. pNamespace->AddRef();
  1745. pThis->m_pNamespace = pNamespace;
  1746. //Let CIMOM know you are initialized
  1747. pInitSink->SetStatus(WBEM_S_INITIALIZED, 0);
  1748. return WBEM_S_NO_ERROR;
  1749. }
  1750. /////////////////////////////////////////////////////////////////////////////
  1751. // CMsieCtrl::XWbemServices
  1752. STDMETHODIMP_(ULONG) CMsieCtrl::XWbemServices::AddRef()
  1753. {
  1754. METHOD_PROLOGUE(CMsieCtrl, WbemServices)
  1755. return pThis->ExternalAddRef();
  1756. }
  1757. STDMETHODIMP_(ULONG) CMsieCtrl::XWbemServices::Release()
  1758. {
  1759. METHOD_PROLOGUE(CMsieCtrl, WbemServices)
  1760. return pThis->ExternalRelease();
  1761. }
  1762. STDMETHODIMP CMsieCtrl::XWbemServices::QueryInterface(REFIID iid, LPVOID* ppvObj)
  1763. {
  1764. METHOD_PROLOGUE(CMsieCtrl, WbemServices)
  1765. return pThis->ExternalQueryInterface(&iid, ppvObj);
  1766. }
  1767. SCODE CMsieCtrl::XWbemServices::CreateInstanceEnumAsync(const BSTR RefStr, long lFlags, IWbemContext *pCtx, IWbemObjectSink *pHandler)
  1768. {
  1769. METHOD_PROLOGUE(CMsieCtrl, WbemServices)
  1770. IWbemClassObject *pClass = NULL;
  1771. IWbemClassObject **ppInstances = NULL;
  1772. SCODE sc;
  1773. void **ppData;
  1774. IEDataType enType;
  1775. long cInstances, lIndex;
  1776. CoImpersonateClient();
  1777. // Do a check of arguments and make sure we have pointer to Namespace
  1778. if (pHandler == NULL || pThis->m_pNamespace == NULL)
  1779. return WBEM_E_INVALID_PARAMETER;
  1780. // Get a class object from CIMOM
  1781. sc = pThis->m_pNamespace->GetObject(RefStr, 0, pCtx, &pClass, NULL);
  1782. if (sc != S_OK)
  1783. return WBEM_E_FAILED;
  1784. if (pThis->GetIEType(RefStr, enType))
  1785. {
  1786. theApp.AppGetIEData(enType, &cInstances, (void***)&ppData);
  1787. ppInstances = (IWbemClassObject**)new LPVOID[cInstances];
  1788. for (lIndex = 0; lIndex < cInstances; lIndex++)
  1789. {
  1790. // Create an instance object and fill it will appropriate Office data
  1791. sc = pClass->SpawnInstance(0, &ppInstances[lIndex]);
  1792. if (SUCCEEDED(sc))
  1793. {
  1794. pThis->SetIEProperties(enType, ppData[lIndex], ppInstances[lIndex]);
  1795. }
  1796. }
  1797. theApp.AppDeleteIEData(enType, cInstances, ppData);
  1798. }
  1799. else
  1800. {
  1801. sc = WBEM_E_NOT_FOUND;
  1802. }
  1803. pClass->Release();
  1804. if (SUCCEEDED(sc))
  1805. {
  1806. // Send the instances to the caller
  1807. pHandler->Indicate(cInstances, ppInstances);
  1808. for (lIndex = 0; lIndex < cInstances; lIndex++)
  1809. ppInstances[lIndex]->Release();
  1810. }
  1811. // Clean up
  1812. if (ppInstances)
  1813. delete []ppInstances;
  1814. // Set status
  1815. pHandler->SetStatus(0, sc, NULL, NULL);
  1816. return sc;
  1817. }
  1818. bool CMsieCtrl::GetIEType(const BSTR classStr, IEDataType &enType)
  1819. {
  1820. bool bRet = true;
  1821. CString strClass(classStr);
  1822. if (strClass == _T("MicrosoftIE_Summary")) enType = SummaryType;
  1823. else if (strClass == _T("MicrosoftIE_FileVersion")) enType = FileVersionType;
  1824. else if (strClass == _T("MicrosoftIE_ConnectionSummary")) enType = ConnSummaryType;
  1825. else if (strClass == _T("MicrosoftIE_LanSettings")) enType = LanSettingsType;
  1826. else if (strClass == _T("MicrosoftIE_ConnectionSettings")) enType = ConnSettingsType;
  1827. else if (strClass == _T("MicrosoftIE_Cache")) enType = CacheType;
  1828. else if (strClass == _T("MicrosoftIE_Object")) enType = ObjectType;
  1829. else if (strClass == _T("MicrosoftIE_Certificate")) enType = CertificateType;
  1830. else if (strClass == _T("MicrosoftIE_Publisher")) enType = PublisherType;
  1831. else if (strClass == _T("MicrosoftIE_Security")) enType = SecurityType;
  1832. else
  1833. {
  1834. bRet = false;
  1835. }
  1836. return bRet;
  1837. }
  1838. void CMsieCtrl::ConvertDateToWbemString(COleVariant &var)
  1839. {
  1840. COleDateTime dateTime;
  1841. CString strDateTime;
  1842. dateTime = var.date;
  1843. strDateTime = dateTime.Format(_T("%Y%m%d%H%M%S.******+***"));
  1844. var = strDateTime.AllocSysString();
  1845. }
  1846. void CMsieCtrl::SetIEProperties(IEDataType enType, void *pIEData, IWbemClassObject *pInstance)
  1847. {
  1848. if (enType == SummaryType)
  1849. {
  1850. IE_SUMMARY *pData = (IE_SUMMARY*)pIEData;
  1851. SETPROPERTY(Name);
  1852. SETPROPERTY(Version);
  1853. SETPROPERTY(Build);
  1854. SETPROPERTY(ProductID);
  1855. SETPROPERTY(Path);
  1856. SETPROPERTY(Language);
  1857. SETPROPERTY(ActivePrinter);
  1858. SETPROPERTY(CipherStrength);
  1859. SETPROPERTY(ContentAdvisor);
  1860. SETPROPERTY(IEAKInstall);
  1861. }
  1862. else if (enType == FileVersionType)
  1863. {
  1864. IE_FILE_VERSION *pData = (IE_FILE_VERSION*)pIEData;
  1865. CString strVersion, strFileMissing;
  1866. SETPROPERTY(File);
  1867. SETPROPERTY(Version);
  1868. // don't set rest of properties if file is missing
  1869. strVersion = pData->Version.bstrVal;
  1870. strFileMissing.LoadString(IDS_FILE_MISSING);
  1871. if (strFileMissing != strVersion)
  1872. {
  1873. SETPROPERTY(Size);
  1874. SETPROPERTY(Date);
  1875. SETPROPERTY(Path);
  1876. SETPROPERTY(Company);
  1877. }
  1878. }
  1879. else if (enType == ConnSummaryType)
  1880. {
  1881. IE_CONN_SUMMARY *pData = (IE_CONN_SUMMARY*)pIEData;
  1882. SETPROPERTY(ConnectionPreference);
  1883. SETPROPERTY(EnableHttp11);
  1884. SETPROPERTY(ProxyHttp11);
  1885. }
  1886. else if (enType == LanSettingsType)
  1887. {
  1888. IE_LAN_SETTINGS *pData = (IE_LAN_SETTINGS*)pIEData;
  1889. SETPROPERTY(AutoConfigProxy);
  1890. SETPROPERTY(AutoProxyDetectMode);
  1891. SETPROPERTY(AutoConfigURL);
  1892. SETPROPERTY(Proxy);
  1893. SETPROPERTY(ProxyServer);
  1894. SETPROPERTY(ProxyOverride);
  1895. }
  1896. else if (enType == ConnSettingsType)
  1897. {
  1898. IE_CONN_SETTINGS *pData = (IE_CONN_SETTINGS*)pIEData;
  1899. SETPROPERTY(Name);
  1900. SETPROPERTY(Default);
  1901. SETPROPERTY(AutoProxyDetectMode);
  1902. SETPROPERTY(AutoConfigURL);
  1903. SETPROPERTY(Proxy);
  1904. SETPROPERTY(ProxyServer);
  1905. SETPROPERTY(ProxyOverride);
  1906. SETPROPERTY(AllowInternetPrograms);
  1907. SETPROPERTY(RedialAttempts);
  1908. SETPROPERTY(RedialWait);
  1909. SETPROPERTY(DisconnectIdleTime);
  1910. SETPROPERTY(AutoDisconnect);
  1911. SETPROPERTY(Modem);
  1912. SETPROPERTY(DialUpServer);
  1913. SETPROPERTY(NetworkLogon);
  1914. SETPROPERTY(SoftwareCompression);
  1915. SETPROPERTY(EncryptedPassword);
  1916. SETPROPERTY(DataEncryption);
  1917. SETPROPERTY(NetworkProtocols);
  1918. SETPROPERTY(ServerAssignedIPAddress);
  1919. SETPROPERTY(IPAddress);
  1920. SETPROPERTY(ServerAssignedNameServer);
  1921. SETPROPERTY(PrimaryDNS);
  1922. SETPROPERTY(SecondaryDNS);
  1923. SETPROPERTY(PrimaryWINS);
  1924. SETPROPERTY(SecondaryWINS);
  1925. SETPROPERTY(IPHeaderCompression);
  1926. SETPROPERTY(DefaultGateway);
  1927. SETPROPERTY(ScriptFileName);
  1928. }
  1929. else if (enType == CacheType)
  1930. {
  1931. IE_CACHE *pData = (IE_CACHE*)pIEData;
  1932. SETPROPERTY(PageRefreshType);
  1933. SETPROPERTY(TempInternetFilesFolder);
  1934. SETPROPERTY(TotalDiskSpace);
  1935. SETPROPERTY(AvailableDiskSpace);
  1936. SETPROPERTY(MaxCacheSize);
  1937. SETPROPERTY(AvailableCacheSize);
  1938. }
  1939. else if (enType == ObjectType)
  1940. {
  1941. IE_OBJECT *pData = (IE_OBJECT*)pIEData;
  1942. SETPROPERTY(ProgramFile);
  1943. SETPROPERTY(Status);
  1944. SETPROPERTY(CodeBase);
  1945. }
  1946. else if (enType == CertificateType)
  1947. {
  1948. IE_CERTIFICATE *pData = (IE_CERTIFICATE*)pIEData;
  1949. SETPROPERTY(Type);
  1950. SETPROPERTY(IssuedTo);
  1951. SETPROPERTY(IssuedBy);
  1952. SETPROPERTY(Validity);
  1953. SETPROPERTY(SignatureAlgorithm);
  1954. }
  1955. else if (enType == PublisherType)
  1956. {
  1957. IE_PUBLISHER *pData = (IE_PUBLISHER*)pIEData;
  1958. SETPROPERTY(Name);
  1959. }
  1960. else if (enType == SecurityType)
  1961. {
  1962. IE_SECURITY *pData = (IE_SECURITY*)pIEData;
  1963. SETPROPERTY(Zone);
  1964. SETPROPERTY(Level);
  1965. }
  1966. }