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.

804 lines
25 KiB

  1. #include "precomp.h"
  2. #include "resource.h"
  3. #include "rsop.h"
  4. // context.cpp
  5. extern INT_PTR CALLBACK RSoPDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
  6. extern void ExportSettings();
  7. unsigned int CSnapIn::m_cfNodeType = RegisterClipboardFormat(CCF_NODETYPE);
  8. GUID g_guidSnapinExt = CLSID_IEAKSnapinExt;
  9. GUID g_guidRSoPSnapinExt = CLSID_IEAKRSoPSnapinExt;
  10. GUID g_guidClientExt = CLSID_IEAKClientExt;
  11. ///////////////////////////////////////////////////////////////////////////////
  12. // //
  13. // CSnapIn object implementation //
  14. // //
  15. ///////////////////////////////////////////////////////////////////////////////
  16. CSnapIn::CSnapIn(CComponentData *pComponent)
  17. {
  18. m_cRef = 1;
  19. InterlockedIncrement(&g_cRefThisDll);
  20. m_pcd = pComponent;
  21. m_pConsole = NULL;
  22. m_pResult = NULL;
  23. m_pHeader = NULL;
  24. m_pImageResult = NULL;
  25. m_pConsoleVerb = NULL;
  26. m_pDisplayHelp = NULL;
  27. m_nColumnSize1 = 180;
  28. m_nColumnSize2 = 270;
  29. m_lViewMode = LVS_REPORT;
  30. m_lpCookieList = NULL;
  31. *(m_pcd->m_szInsFile) = TEXT('\0');
  32. LoadString(g_hInstance, IDS_HDR_NAME, m_szColumn1, ARRAYSIZE(m_szColumn1));
  33. LoadString(g_hInstance, IDS_HDR_DESC, m_szColumn2, ARRAYSIZE(m_szColumn2));
  34. }
  35. CSnapIn::~CSnapIn()
  36. {
  37. DeleteCookieList(m_lpCookieList);
  38. InterlockedDecrement(&g_cRefThisDll);
  39. }
  40. HRESULT CSnapIn::AddMenuItems(LPDATAOBJECT piDataObject,
  41. LPCONTEXTMENUCALLBACK piCallback,
  42. long __RPC_FAR *pInsertionAllowed)
  43. {
  44. UNREFERENCED_PARAMETER(piDataObject);
  45. UNREFERENCED_PARAMETER(piCallback);
  46. UNREFERENCED_PARAMETER(pInsertionAllowed);
  47. return S_FALSE;
  48. }
  49. HRESULT CSnapIn::SignalPolicyChanged(BOOL bMachine, BOOL bAdd, GUID *pGuidExtension,
  50. GUID *pGuidSnapin)
  51. {
  52. return m_pcd->m_pGPTInformation->PolicyChanged(bMachine, bAdd, pGuidExtension, pGuidSnapin);
  53. }
  54. LPCTSTR CSnapIn::GetInsFile()
  55. {
  56. return m_pcd->GetInsFile();
  57. }
  58. ///////////////////////////////////////////////////////////////////////////////
  59. // //
  60. // CSnapIn object implementation (IUnknown) //
  61. // //
  62. ///////////////////////////////////////////////////////////////////////////////
  63. HRESULT CSnapIn::QueryInterface (REFIID riid, void **ppv)
  64. {
  65. if (IsEqualIID(riid, IID_IComponent) || IsEqualIID(riid, IID_IUnknown))
  66. {
  67. *ppv = (LPCOMPONENT)this;
  68. m_cRef++;
  69. return S_OK;
  70. }
  71. else if (IsEqualIID(riid, IID_IExtendPropertySheet))
  72. {
  73. *ppv = (LPEXTENDPROPERTYSHEET)this;
  74. m_cRef++;
  75. return S_OK;
  76. }
  77. else if (IsEqualIID(riid, IID_IExtendContextMenu))
  78. {
  79. *ppv = (LPEXTENDCONTEXTMENU)this;
  80. m_cRef++;
  81. return S_OK;
  82. }
  83. else
  84. {
  85. *ppv = NULL;
  86. return E_NOINTERFACE;
  87. }
  88. }
  89. ULONG CSnapIn::AddRef (void)
  90. {
  91. return ++m_cRef;
  92. }
  93. ULONG CSnapIn::Release (void)
  94. {
  95. if (--m_cRef == 0) {
  96. delete this;
  97. return 0;
  98. }
  99. return m_cRef;
  100. }
  101. ///////////////////////////////////////////////////////////////////////////////
  102. // //
  103. // CSnapIn object implementation (IComponent) //
  104. // //
  105. ///////////////////////////////////////////////////////////////////////////////
  106. STDMETHODIMP CSnapIn::Initialize(LPCONSOLE lpConsole)
  107. {
  108. HRESULT hr;
  109. // Save the IConsole pointer
  110. m_pConsole = lpConsole;
  111. m_pConsole->AddRef();
  112. hr = m_pConsole->QueryInterface(IID_IHeaderCtrl,
  113. reinterpret_cast<void**>(&m_pHeader));
  114. // Give the console the header control interface pointer
  115. if (SUCCEEDED(hr))
  116. m_pConsole->SetHeader(m_pHeader);
  117. m_pConsole->QueryInterface(IID_IResultData,
  118. reinterpret_cast<void**>(&m_pResult));
  119. m_pConsole->QueryResultImageList(&m_pImageResult);
  120. m_pConsole->QueryConsoleVerb(&m_pConsoleVerb);
  121. m_pConsole->QueryInterface(IID_IDisplayHelp,
  122. reinterpret_cast<void**>(&m_pDisplayHelp));
  123. return S_OK;
  124. }
  125. STDMETHODIMP CSnapIn::Destroy(MMC_COOKIE cookie)
  126. {
  127. UNREFERENCED_PARAMETER(cookie);
  128. if (m_pConsole != NULL)
  129. {
  130. m_pConsole->SetHeader(NULL);
  131. m_pConsole->Release();
  132. m_pConsole = NULL;
  133. }
  134. if (m_pHeader != NULL)
  135. {
  136. m_pHeader->Release();
  137. m_pHeader = NULL;
  138. }
  139. if (m_pResult != NULL)
  140. {
  141. m_pResult->Release();
  142. m_pResult = NULL;
  143. }
  144. if (m_pImageResult != NULL)
  145. {
  146. m_pImageResult->Release();
  147. m_pImageResult = NULL;
  148. }
  149. if (m_pConsoleVerb != NULL)
  150. {
  151. m_pConsoleVerb->Release();
  152. m_pConsoleVerb = NULL;
  153. }
  154. if (m_pDisplayHelp != NULL)
  155. {
  156. m_pDisplayHelp->Release();
  157. m_pDisplayHelp = NULL;
  158. }
  159. return S_OK;
  160. }
  161. STDMETHODIMP CSnapIn::Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param)
  162. {
  163. HRESULT hr = S_OK;
  164. UNREFERENCED_PARAMETER(param);
  165. switch(event)
  166. {
  167. case MMCN_DBLCLICK:
  168. hr = S_FALSE;
  169. break;
  170. case MMCN_ADD_IMAGES:
  171. HBITMAP hbmp16x16;
  172. HBITMAP hbmp32x32;
  173. hbmp16x16 = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_IEAKSNAPINEXT_16));
  174. hbmp32x32 = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_IEAKSNAPINEXT_32));
  175. // Set the images
  176. m_pImageResult->ImageListSetStrip(reinterpret_cast<LONG_PTR *>(hbmp16x16),
  177. reinterpret_cast<LONG_PTR *>(hbmp32x32),
  178. 0, RGB(255, 0, 255));
  179. DeleteObject(hbmp16x16);
  180. DeleteObject(hbmp32x32);
  181. break;
  182. case MMCN_SHOW:
  183. if (arg == TRUE)
  184. {
  185. RESULTDATAITEM resultItem;
  186. LPIEAKDATAOBJECT pIEAKDataObject;
  187. MMC_COOKIE cookie;
  188. DWORD dwIndex;
  189. INT i;
  190. //
  191. // Get the cookie of the scope pane item
  192. //
  193. hr = lpDataObject->QueryInterface(IID_IIEAKDataObject, (LPVOID *)&pIEAKDataObject);
  194. if (FAILED(hr))
  195. return S_OK;
  196. hr = pIEAKDataObject->GetCookie(&cookie);
  197. pIEAKDataObject->Release(); // release initial ref
  198. if (FAILED(hr))
  199. return S_OK;
  200. dwIndex = PtrToUlong(((LPIEAKMMCCOOKIE)cookie)->lpItem);
  201. //
  202. // Prepare the view
  203. //
  204. m_pHeader->InsertColumn(0, m_szColumn1, LVCFMT_LEFT, m_nColumnSize1);
  205. m_pHeader->InsertColumn(1, m_szColumn2, LVCFMT_LEFT, m_nColumnSize2);
  206. m_pResult->SetViewMode(m_lViewMode);
  207. //
  208. // Set the ins file so we can check for dupe GPO pages
  209. //
  210. m_pcd->SetInsFile();
  211. // check to see if we need to enumerate ADM files if this is the adm
  212. // node
  213. if (dwIndex == ADM_NAMESPACE_ITEM)
  214. {
  215. EnterCriticalSection(&g_LayoutCriticalSection);
  216. if (g_NameSpace[dwIndex].pResultItems == NULL)
  217. {
  218. GetAdmFileList(&(g_NameSpace[dwIndex].pResultItems),
  219. &(g_NameSpace[dwIndex].cResultItems), ROLE_CORP);
  220. for (i = 0; i < g_NameSpace[dwIndex].cResultItems; i++)
  221. {
  222. g_NameSpace[dwIndex].pResultItems[i].dwNameSpaceItem = ADM_NAMESPACE_ITEM;
  223. g_NameSpace[dwIndex].pResultItems[i].iDlgID = IDD_ADM;
  224. g_NameSpace[dwIndex].pResultItems[i].iImage = 6;
  225. g_NameSpace[dwIndex].pResultItems[i].iNamePrefID = -1;
  226. g_NameSpace[dwIndex].pResultItems[i].pszNamePref = NULL;
  227. g_NameSpace[dwIndex].pResultItems[i].pfnDlgProc = AdmDlgProc;
  228. g_NameSpace[dwIndex].pResultItems[i].pcszHelpTopic = HELP_FILENAME TEXT("::/ieakmmc.htm");
  229. }
  230. }
  231. LeaveCriticalSection(&g_LayoutCriticalSection);
  232. }
  233. //
  234. // Add result pane items for this node
  235. //
  236. for (i = 0; i < g_NameSpace[dwIndex].cResultItems; i++)
  237. {
  238. LPIEAKMMCCOOKIE lpCookie = (LPIEAKMMCCOOKIE)CoTaskMemAlloc(sizeof(IEAKMMCCOOKIE));
  239. lpCookie->lpItem = &g_NameSpace[dwIndex].pResultItems[i];
  240. lpCookie->lpParentItem = this;
  241. lpCookie->pNext = NULL;
  242. AddItemToCookieList(&m_lpCookieList, lpCookie);
  243. resultItem.mask = RDI_STR | RDI_IMAGE | RDI_PARAM;
  244. resultItem.str = MMC_CALLBACK;
  245. resultItem.nImage = g_NameSpace[dwIndex].pResultItems[i].iImage;
  246. resultItem.lParam = (LPARAM)lpCookie;
  247. m_pResult->InsertItem(&resultItem);
  248. }
  249. }
  250. else
  251. {
  252. m_pHeader->GetColumnWidth(0, &m_nColumnSize1);
  253. m_pHeader->GetColumnWidth(0, &m_nColumnSize2);
  254. m_pResult->GetViewMode(&m_lViewMode);
  255. }
  256. break;
  257. case MMCN_SELECT:
  258. if (m_pConsoleVerb != NULL)
  259. {
  260. LPIEAKDATAOBJECT pIEAKDataObject;
  261. DATA_OBJECT_TYPES type;
  262. MMC_COOKIE cookie;
  263. DWORD dwIndex;
  264. //
  265. // Set the default verb to open
  266. //
  267. m_pConsoleVerb->SetDefaultVerb(MMC_VERB_OPEN);
  268. //
  269. // See if this is one of our items.
  270. //
  271. hr = lpDataObject->QueryInterface(IID_IIEAKDataObject, (LPVOID *)&pIEAKDataObject);
  272. if (FAILED(hr))
  273. break;
  274. pIEAKDataObject->GetType(&type);
  275. pIEAKDataObject->GetCookie(&cookie);
  276. pIEAKDataObject->Release();
  277. dwIndex = PtrToUlong(((LPIEAKMMCCOOKIE)cookie)->lpItem);
  278. //
  279. // If this is a result pane item, enable the Properties menu item
  280. //
  281. if (type == CCT_RESULT)
  282. {
  283. m_pConsoleVerb->SetVerbState(MMC_VERB_PROPERTIES, ENABLED, TRUE);
  284. //
  285. // If this is a result pane item, then change the default
  286. // verb to Properties.
  287. //
  288. if (type == CCT_RESULT)
  289. m_pConsoleVerb->SetDefaultVerb(MMC_VERB_PROPERTIES);
  290. }
  291. }
  292. break;
  293. case MMCN_CONTEXTHELP:
  294. if (m_pDisplayHelp != NULL)
  295. {
  296. LPOLESTR pszHelpTopic;
  297. LPIEAKDATAOBJECT pIEAKDataObject;
  298. MMC_COOKIE cookie;
  299. hr = lpDataObject->QueryInterface(IID_IIEAKDataObject, (LPVOID *)&pIEAKDataObject);
  300. if (FAILED(hr))
  301. return S_OK;
  302. hr = pIEAKDataObject->GetCookie(&cookie);
  303. pIEAKDataObject->Release();
  304. if (FAILED(hr))
  305. return S_OK;
  306. if ((pszHelpTopic = (LPOLESTR) CoTaskMemAlloc(64 * sizeof(WCHAR))) != NULL)
  307. {
  308. LPIEAKMMCCOOKIE lpCookie = (LPIEAKMMCCOOKIE)cookie;
  309. // determine whether cookie is for scope pane item for result pane item
  310. if (PtrToUlong(lpCookie->lpItem) >= NUM_NAMESPACE_ITEMS)
  311. {
  312. LPRESULTITEM lpResultItem = (LPRESULTITEM)lpCookie->lpItem;
  313. StrCpy(pszHelpTopic, HELP_FILENAME TEXT("::/"));
  314. StrCat(pszHelpTopic, lpResultItem->pcszHelpTopic);
  315. }
  316. else
  317. StrCpy(pszHelpTopic, HELP_FILENAME TEXT("::/ieakmmc.htm"));
  318. m_pDisplayHelp->ShowTopic (pszHelpTopic);
  319. }
  320. }
  321. break;
  322. case MMCN_COLUMNS_CHANGED:
  323. hr = S_OK; // return S_OK so MMC will handle when the user add/removes columns
  324. break;
  325. default:
  326. hr = E_UNEXPECTED;
  327. break;
  328. }
  329. return hr;
  330. }
  331. STDMETHODIMP CSnapIn::QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT *ppDataObject)
  332. {
  333. return m_pcd->QueryDataObject(cookie, type, ppDataObject);
  334. }
  335. STDMETHODIMP CSnapIn::GetDisplayInfo(LPRESULTDATAITEM pResult)
  336. {
  337. if (pResult != NULL)
  338. {
  339. if (pResult->bScopeItem == TRUE)
  340. {
  341. DWORD dwIndex = PtrToUlong(((LPIEAKMMCCOOKIE)pResult->lParam)->lpItem);
  342. if (pResult->mask & RDI_STR)
  343. {
  344. switch (pResult->nCol)
  345. {
  346. case 0:
  347. CreateBufandLoadString(g_hInstance, g_NameSpace[dwIndex].iNameID,
  348. &g_NameSpace[dwIndex].pszName, &pResult->str, MAX_DISPLAYNAME_SIZE);
  349. break;
  350. case 1:
  351. CreateBufandLoadString(g_hInstance, g_NameSpace[dwIndex].iDescID,
  352. &g_NameSpace[dwIndex].pszDesc, &pResult->str, MAX_PATH);
  353. break;
  354. default:
  355. pResult->str = L"";
  356. break;
  357. }
  358. }
  359. if (pResult->mask & RDI_IMAGE)
  360. {
  361. pResult->nImage = dwIndex;
  362. }
  363. }
  364. else
  365. {
  366. if (pResult->mask & RDI_STR)
  367. {
  368. LPRESULTITEM lpResultItem = (LPRESULTITEM)((LPIEAKMMCCOOKIE)pResult->lParam)->lpItem;
  369. switch (pResult->nCol)
  370. {
  371. case 0:
  372. if (InsIsKeyEmpty(IS_BRANDING, IK_GPE_ONETIME_GUID, m_pcd->GetInsFile()) ||
  373. (lpResultItem->iNamePrefID == -1))
  374. {
  375. CreateBufandLoadString(g_hUIInstance, lpResultItem->iNameID,
  376. &lpResultItem->pszName, &pResult->str, MAX_DISPLAYNAME_SIZE);
  377. }
  378. else
  379. {
  380. CreateBufandLoadString(g_hUIInstance, lpResultItem->iNamePrefID,
  381. &lpResultItem->pszNamePref, &pResult->str, MAX_DISPLAYNAME_SIZE);
  382. }
  383. break;
  384. case 1:
  385. CreateBufandLoadString(g_hUIInstance, lpResultItem->iDescID,
  386. &lpResultItem->pszDesc, &pResult->str, MAX_PATH);
  387. break;
  388. }
  389. if (pResult->str == NULL)
  390. pResult->str = (LPOLESTR)L"";
  391. }
  392. }
  393. }
  394. return S_OK;
  395. }
  396. STDMETHODIMP CSnapIn::GetResultViewType(MMC_COOKIE cookie, LPOLESTR *ppViewType,
  397. long *pViewOptions)
  398. {
  399. UNREFERENCED_PARAMETER(cookie);
  400. UNREFERENCED_PARAMETER(ppViewType);
  401. UNREFERENCED_PARAMETER(pViewOptions);
  402. return S_FALSE;
  403. }
  404. STDMETHODIMP CSnapIn::CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB)
  405. {
  406. HRESULT hr = S_FALSE;
  407. LPIEAKDATAOBJECT pIEAKDataObjectA, pIEAKDataObjectB;
  408. MMC_COOKIE cookie1, cookie2;
  409. if (lpDataObjectA == NULL || lpDataObjectB == NULL)
  410. return E_POINTER;
  411. //
  412. // QI for the private IEAKDataObject interface
  413. //
  414. if (FAILED(lpDataObjectA->QueryInterface(IID_IIEAKDataObject,
  415. (LPVOID *)&pIEAKDataObjectA)))
  416. {
  417. return S_FALSE;
  418. }
  419. if (FAILED(lpDataObjectB->QueryInterface(IID_IIEAKDataObject,
  420. (LPVOID *)&pIEAKDataObjectB)))
  421. {
  422. pIEAKDataObjectA->Release();
  423. return S_FALSE;
  424. }
  425. pIEAKDataObjectA->GetCookie(&cookie1);
  426. pIEAKDataObjectB->GetCookie(&cookie2);
  427. if (cookie1 == cookie2)
  428. hr = S_OK;
  429. else
  430. {
  431. LPIEAKMMCCOOKIE lpCookie1 = (LPIEAKMMCCOOKIE)cookie1;
  432. LPIEAKMMCCOOKIE lpCookie2 = (LPIEAKMMCCOOKIE)cookie2;
  433. if (lpCookie1->lpItem == lpCookie2->lpItem)
  434. {
  435. CSnapIn * pCS1 = (CSnapIn *)lpCookie1->lpParentItem;
  436. CSnapIn * pCS2 = (CSnapIn *)lpCookie2->lpParentItem;
  437. // check if these are referencing the same GPO
  438. if ((pCS1 == pCS2) ||
  439. (StrCmpI(pCS1->GetInsFile(), pCS2->GetInsFile()) == 0))
  440. hr = S_OK;
  441. }
  442. }
  443. pIEAKDataObjectA->Release();
  444. pIEAKDataObjectB->Release();
  445. return hr;
  446. }
  447. ///////////////////////////////////////////////////////////////////////////////
  448. // Private helper functions
  449. ///////////////////////////////////////////////////////////////////////////////
  450. HRESULT CSnapIn::AddPrecedencePropPage(LPPROPERTYSHEETCALLBACK lpProvider,
  451. LPPROPSHEETCOOKIE lpPropSheetCookie,
  452. LPCTSTR pszTitle, long nPageID)
  453. {
  454. HRESULT hr = E_FAIL;
  455. __try
  456. {
  457. LPRSOPPAGECOOKIE lpRSOPPageCookie = (LPRSOPPAGECOOKIE)CoTaskMemAlloc(sizeof(RSOPPAGECOOKIE));
  458. lpRSOPPageCookie->psCookie = lpPropSheetCookie;
  459. lpRSOPPageCookie->nPageID = nPageID;
  460. PROPSHEETPAGE pspRSoP;
  461. pspRSoP.dwSize = sizeof(PROPSHEETPAGE);
  462. pspRSoP.dwFlags = PSP_HASHELP | PSP_USETITLE; // no callback
  463. pspRSoP.hInstance = g_hInstance;
  464. pspRSoP.pszTemplate = MAKEINTRESOURCE(IDD_RSOPP);
  465. pspRSoP.pfnDlgProc = RSoPDlgProc;
  466. // For regular pages, when callback fires on closing, it deletes a buffer.
  467. // We don't to do this twice! However, since we're passing a different lParam,
  468. // this won't be a problem.
  469. pspRSoP.pfnCallback = PropSheetPageProc;
  470. pspRSoP.lParam = (LPARAM)lpRSOPPageCookie;
  471. pspRSoP.pszTitle = pszTitle;
  472. HPROPSHEETPAGE hPrecedencePage = CreatePropertySheetPage(&pspRSoP);
  473. if (hPrecedencePage != NULL)
  474. hr = lpProvider->AddPage(hPrecedencePage);
  475. else
  476. hr = E_FAIL;
  477. }
  478. __except(TRUE)
  479. {
  480. }
  481. return hr;
  482. }
  483. ///////////////////////////////////////////////////////////////////////////////
  484. // //
  485. // CSnapIn object implementation (IExtendPropertySheet) //
  486. // //
  487. ///////////////////////////////////////////////////////////////////////////////
  488. STDMETHODIMP CSnapIn::CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  489. LONG_PTR handle, LPDATAOBJECT lpDataObject)
  490. {
  491. HRESULT hr = S_OK;
  492. HPROPSHEETPAGE hPage;
  493. PROPSHEETPAGE psp;
  494. LPIEAKDATAOBJECT pIEAKDataObject;
  495. LPRESULTITEM pItem;
  496. LPPROPSHEETCOOKIE lpPropSheetCookie;
  497. MMC_COOKIE cookie;
  498. UNREFERENCED_PARAMETER(handle);
  499. //
  500. // Make sure this is one of our objects
  501. //
  502. if (FAILED(lpDataObject->QueryInterface(IID_IIEAKDataObject,
  503. (LPVOID *)&pIEAKDataObject)))
  504. {
  505. return hr;
  506. }
  507. //
  508. // Get the cookie
  509. //
  510. pIEAKDataObject->GetCookie(&cookie);
  511. pIEAKDataObject->Release();
  512. pItem = (LPRESULTITEM)((LPIEAKMMCCOOKIE)cookie)->lpItem;
  513. // check to make sure prop sheet is implemented
  514. if ((pItem->iDlgID == 0) || (pItem->pfnDlgProc == NULL))
  515. return S_OK;
  516. // set the ins file
  517. m_pcd->SetInsFile();
  518. // Block if we are in preference mode and this setting is not accessible to the user.
  519. // In RSoP mode, just avoid this. The right thing to do would be to pop up this
  520. // error msg if the following criteria are met and all of the GPOs are in preference mode.
  521. if (!IsRSoP())
  522. {
  523. if ((pItem->iNamePrefID == -1) && (pItem->dwNameSpaceItem != ADM_NAMESPACE_ITEM) &&
  524. !InsIsKeyEmpty(IS_BRANDING, IK_GPE_ONETIME_GUID, m_pcd->GetInsFile()))
  525. {
  526. SIEErrorMessageBox(NULL, IDS_ERROR_ONETIME);
  527. return S_FALSE;
  528. }
  529. }
  530. // construct the cookie
  531. lpPropSheetCookie = (LPPROPSHEETCOOKIE)CoTaskMemAlloc(sizeof(PROPSHEETCOOKIE));
  532. lpPropSheetCookie->lpResultItem = pItem;
  533. lpPropSheetCookie->pCS = this;
  534. //
  535. // Initialize the common fields in the property sheet structure
  536. //
  537. psp.dwSize = sizeof(PROPSHEETPAGE);
  538. psp.dwFlags = PSP_HASHELP | PSP_USECALLBACK;
  539. psp.hInstance = g_hUIInstance;
  540. psp.pszTemplate = MAKEINTRESOURCE(pItem->iDlgID);
  541. psp.pfnDlgProc = pItem->pfnDlgProc;
  542. psp.pfnCallback = PropSheetPageProc;
  543. psp.lParam = (LPARAM)lpPropSheetCookie;
  544. hPage = CreatePropertySheetPage(&psp);
  545. if (hPage != NULL)
  546. hr = lpProvider->AddPage(hPage);
  547. else
  548. hr = E_FAIL;
  549. if (SUCCEEDED(hr) && IsRSoP())
  550. {
  551. switch(pItem->iDlgID)
  552. {
  553. // Browser User Interface
  554. case IDD_BTITLE:
  555. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_TITLE_PREC), 0);
  556. break;
  557. case IDD_CUSTICON:
  558. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_SMALLLOGO_PREC), 0);
  559. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_LARGELOGO_PREC), 1);
  560. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_SMALLBMP_PREC), 2);
  561. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_LARGEBMP_PREC), 3);
  562. break;
  563. case IDD_BTOOLBARS:
  564. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_TOOLBARBUTTON_PREC), 0);
  565. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_TOOLBARBMP_PREC), 1);
  566. break;
  567. // Connection
  568. case IDD_CONNECTSET:
  569. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_PRECEDENCE), 0);
  570. break;
  571. case IDD_QUERYAUTOCONFIG:
  572. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_AUTODETECT_CFG_PREC), 0);
  573. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_AUTOCFG_ENABLE_PREC), 1);
  574. break;
  575. case IDD_PROXY:
  576. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_PRECEDENCE), 0);
  577. break;
  578. case IDD_UASTRDLG:
  579. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_PRECEDENCE), 0);
  580. break;
  581. // URLs
  582. case IDD_FAVORITES:
  583. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_FAV_ONTOP_PREC), 0);
  584. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_DEL_FAVS_PREC), 1);
  585. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_FAVS_PREC), 2);
  586. break;
  587. case IDD_STARTSEARCH:
  588. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_HOMEPAGE_PREC), 0);
  589. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_SEARCHPAGE_PREC), 1);
  590. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_SUPPORTPAGE_PREC), 2);
  591. break;
  592. // Security
  593. case IDD_SECURITY1:
  594. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_SECZONES_PREC), 0);
  595. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_CONTENTRAT_PREC), 1);
  596. break;
  597. case IDD_SECURITYAUTH:
  598. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_AUTHSECURITY_PREC), 0);
  599. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_PUB_LOCK_PREC), 1);
  600. break;
  601. // Programs
  602. case IDD_PROGRAMS:
  603. AddPrecedencePropPage(lpProvider, lpPropSheetCookie, MAKEINTRESOURCE(IDS_PRECEDENCE), 0);
  604. break;
  605. // Advanced
  606. default:
  607. break;
  608. }
  609. }
  610. return (hr);
  611. }
  612. STDMETHODIMP CSnapIn::QueryPagesFor(LPDATAOBJECT lpDataObject)
  613. {
  614. LPIEAKDATAOBJECT pIEAKDataObject;
  615. DATA_OBJECT_TYPES type;
  616. if (SUCCEEDED(lpDataObject->QueryInterface(IID_IIEAKDataObject,
  617. (LPVOID *)&pIEAKDataObject)))
  618. {
  619. pIEAKDataObject->GetType(&type);
  620. pIEAKDataObject->Release();
  621. if (type == CCT_RESULT)
  622. return S_OK;
  623. }
  624. return S_FALSE;
  625. }
  626. STDMETHODIMP CSnapIn::Command(long /*lCommandID*/, LPDATAOBJECT lpDataObject)
  627. {
  628. LPIEAKDATAOBJECT pIEAKDataObject;
  629. if (FAILED(lpDataObject->QueryInterface(IID_IIEAKDataObject,
  630. (LPVOID *)&pIEAKDataObject)))
  631. {
  632. return S_FALSE;
  633. }
  634. pIEAKDataObject->Release();
  635. return E_INVALIDARG;
  636. }