Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

714 lines
23 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1998.
  5. //
  6. // File: common.h
  7. //
  8. // Contents: common definitions used by the main snapin modules
  9. //
  10. // Classes: CResultPane, CScopePane
  11. //
  12. // History: 03-14-1998 stevebl Commented
  13. // 05-20-1998 RahulTh Added CScopePane::DetectUpgrades
  14. // for auto-upgrade detection
  15. // 05-10-2001 RahulTh Added infrastructure for enabling
  16. // theme'ing of UI components.
  17. //
  18. //---------------------------------------------------------------------------
  19. #include "resource.h" // main symbols
  20. #ifndef __mmc_h__
  21. #include <mmc.h>
  22. #endif
  23. #include "objidl.h"
  24. #include "data.h"
  25. #include "gpedit.h"
  26. #include "adeevent.h"
  27. #include "iads.h"
  28. #include <iadsp.h>
  29. #include <ntdsapi.h>
  30. #include <dssec.h>
  31. #include <set>
  32. #include <shfusion.h>
  33. //
  34. // Add theme'ing support. Since we use MFC, we need to perform some additional
  35. // tasks in order to get all our UI elements theme'd. We need this class to
  36. // activate the theme'ing context around any UI that we want theme'd.
  37. //
  38. class CThemeContextActivator
  39. {
  40. public:
  41. CThemeContextActivator() : m_ulActivationCookie(0)
  42. { SHActivateContext (&m_ulActivationCookie); }
  43. ~CThemeContextActivator()
  44. { SHDeactivateContext (m_ulActivationCookie); }
  45. private:
  46. ULONG_PTR m_ulActivationCookie;
  47. };
  48. // Uncomment the next line to re-enable the digital signatures code.
  49. // #define DIGITAL_SIGNATURES 1
  50. // Digital signatures have been cut in faver of the "SAFER" technology.
  51. class CUpgrades; //forward declaration; added RahulTh 5/19/1998.
  52. // private notifications
  53. #define WM_USER_REFRESH (WM_USER + 1000)
  54. #define WM_USER_CLOSE (WM_USER + 1001)
  55. // very big number to be sure that we can always squeeze a DS path into it
  56. #define MAX_DS_PATH 1024
  57. // Note - This is the offset in my image list that represents the folder
  58. const FOLDER_IMAGE_IDX = 0;
  59. const OPEN_FOLDER_IMAGE_IDX = 5;
  60. extern HINSTANCE ghInstance;
  61. extern const CLSID CLSID_Snapin;
  62. extern CLSID CLSID_Temp;
  63. extern const wchar_t * szCLSID_Snapin;
  64. extern const CLSID CLSID_MachineSnapin;
  65. extern const wchar_t * szCLSID_MachineSnapin;
  66. extern const GUID cNodeType;
  67. extern const wchar_t* cszNodeType;
  68. extern GUID guidExtension;
  69. extern GUID guidUserSnapin;
  70. extern GUID guidMachSnapin;
  71. // RSOP GUIDS
  72. extern const CLSID CLSID_RSOP_Snapin;
  73. extern const wchar_t * szCLSID_RSOP_Snapin;
  74. extern const CLSID CLSID_RSOP_MachineSnapin;
  75. extern const wchar_t * szCLSID_RSOP_MachineSnapin;
  76. extern GUID guidRSOPUserSnapin;
  77. extern GUID guidRSOPMachSnapin;
  78. typedef enum NEW_PACKAGE_BEHAVIORS
  79. {
  80. NP_PUBLISHED = 0,
  81. NP_ASSIGNED,
  82. NP_DISABLED,
  83. NP_UPGRADE
  84. } NEW_PACKAGE_BEHAVIOR;
  85. typedef enum tagUPGRADE_DISPOSITION
  86. {
  87. UNINSTALL_EXISTING = 0x0,
  88. BLOCK_INSTALL = 0x1,
  89. INSTALLED_GREATER = 0x2,
  90. INSTALLED_LOWER = 0x4,
  91. INSTALLED_EQUAL = 0x8,
  92. MIGRATE_SETTINGS = 0x10
  93. } UPGRADE_DISPOSITION;
  94. #define IMG_OPENBOX 0
  95. #define IMG_CLOSEDBOX 1
  96. #define IMG_DISABLED 2
  97. #define IMG_PUBLISHED 3
  98. #define IMG_ASSIGNED 4
  99. #define IMG_UPGRADE 5
  100. #define IMG_OPEN_FAILED 6
  101. #define IMG_CLOSED_FAILED 7
  102. #define CFGFILE _T("ADE.CFG")
  103. // Uncomment the next line to return to the old way of deploying packages
  104. // with multiple LCIDs. With this commented only the primary (first)
  105. // LCID gets a deployment.
  106. //#define DEPLOY_MULTIPLE_LCIDS
  107. // Uncomment the next line to include country names in text representations
  108. // of LCIDs.
  109. //#define SHOWCOUNTRY 0
  110. //
  111. // MACROS for allocating and freeing memory via OLE's common allocator: IMalloc.
  112. //
  113. // (NOTE) the Class Store API no longer use IMalloc so thes macros have been
  114. // reverted back to using new and free.
  115. //
  116. //extern IMalloc * g_pIMalloc;
  117. // UNDONE - throw exception on failure
  118. #define OLEALLOC(x) LocalAlloc(0, x)
  119. //#define OLEALLOC(x) g_pIMalloc->Alloc(x)
  120. #define OLESAFE_DELETE(x) if (x) {LocalFree(x); x = NULL;}
  121. //#define OLESAFE_DELETE(x) if (x) {g_pIMalloc->Free(x); x = NULL;}
  122. #define OLESAFE_COPYSTRING(szO, szI) {if (szI) {int i_dontcollidewithanything = wcslen(szI); szO=(OLECHAR *)OLEALLOC(sizeof(OLECHAR) * (i_dontcollidewithanything+1)); if (szO) wcscpy(szO, szI);} else szO=NULL;}
  123. // Keys used in the CFG file.
  124. //
  125. // The CFG file is found in the Applications directory of the SysVol (which
  126. // is the same directory as the script files).
  127. //
  128. // The format of an entry in the CFG file is:
  129. //
  130. // %key%=%data%
  131. //
  132. // where %data% is either an integer or a string as appropriate.
  133. //
  134. // Order is not important and if a key is not present in the CFG file then
  135. // the default setting will be used. Some keys (iDebugLevel and
  136. // fShowPkgDetails) will only be saved in the CFG file if their values are
  137. // different from the default settings.
  138. //
  139. #define KEY_NPBehavior L"Default Deployment"
  140. #define KEY_fCustomDeployment L"Use Custom Deployment"
  141. #define KEY_fUseWizard L"Use Deployment Wizard"
  142. #define KEY_UILevel L"UI Level"
  143. #define KEY_szStartPath L"Start Path"
  144. #define KEY_iDebugLevel L"Debug Level"
  145. #define KEY_fShowPkgDetails L"Package Details"
  146. #define KEY_f32On64 L"Run 32b Apps on 64b"
  147. #define KEY_fZapOn64 L"Run ZAP Apps on 64b"
  148. #define KEY_fExtensionsOnly L"Only Deploy Extension Info"
  149. #define KEY_nUninstallTrackingMonths L"Uninstall Tracking Months"
  150. #define KEY_fUninstallOnPolicyRemoval L"Uninstall On Policy Removal"
  151. typedef struct tagTOOL_DEFAULTS
  152. {
  153. NEW_PACKAGE_BEHAVIOR NPBehavior;
  154. BOOL fCustomDeployment;
  155. BOOL fUseWizard;
  156. INSTALLUILEVEL UILevel;
  157. CString szStartPath;
  158. int iDebugLevel;
  159. BOOL fShowPkgDetails;
  160. ULONG nUninstallTrackingMonths;
  161. BOOL fUninstallOnPolicyRemoval;
  162. BOOL fZapOn64;
  163. BOOL f32On64;
  164. BOOL fExtensionsOnly;
  165. } TOOL_DEFAULTS;
  166. /////////////////////////////////////////////////////////////////////////////
  167. // Snapin
  168. typedef set<long> EXTLIST;
  169. INTERNAL* ExtractInternalFormat(LPDATAOBJECT lpDataObject);
  170. class CToolDefs;
  171. class CToolAdvDefs;
  172. class CTracking;
  173. class CCatList;
  174. class CFileExt;
  175. class CSignatures;
  176. class CScopePane:
  177. public IComponentData,
  178. public IExtendContextMenu,
  179. public IPersistStreamInit,
  180. public IExtendPropertySheet,
  181. public ISnapinAbout,
  182. public ISnapinHelp,
  183. public CComObjectRoot
  184. {
  185. friend class CResultPane;
  186. friend class CDataObject;
  187. public:
  188. CScopePane();
  189. ~CScopePane();
  190. HWND m_hwndMainWindow;
  191. LPRSOPINFORMATION m_pIRSOPInformation; // Interface pointer to the GPT
  192. protected:
  193. LPGPEINFORMATION m_pIGPEInformation; // Interface pointer to the GPT
  194. BOOL m_fRSOPEnumerate; // OK to enumerate RSoP data
  195. BOOL m_fRSOPPolicyFailed; // TRUE if there was a failure applying SI policy
  196. public:
  197. DWORD m_dwRSOPFlags;
  198. virtual IUnknown * GetMyUnknown() = 0;
  199. // IComponentData interface members
  200. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  201. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  202. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  203. STDMETHOD(Destroy)();
  204. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  205. STDMETHOD(GetDisplayInfo)(SCOPEDATAITEM* pScopeDataItem);
  206. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  207. // IExtendContextMenu
  208. public:
  209. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pCallbackUnknown, LONG * pInsertionAllowed);
  210. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  211. public:
  212. // IPersistStreamInit interface members
  213. STDMETHOD(GetClassID)(CLSID *pClassID);
  214. STDMETHOD(IsDirty)();
  215. STDMETHOD(Load)(IStream *pStm);
  216. STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty);
  217. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
  218. STDMETHOD(InitNew)(VOID);
  219. // IExtendPropertySheet interface
  220. public:
  221. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  222. LONG_PTR handle,
  223. LPDATAOBJECT lpIDataObject);
  224. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  225. // ISnapinAbout interface
  226. public:
  227. STDMETHOD(GetSnapinDescription)(LPOLESTR * lpDescription);
  228. STDMETHOD(GetProvider)(LPOLESTR * lpName);
  229. STDMETHOD(GetSnapinVersion)(LPOLESTR * lpVersion);
  230. STDMETHOD(GetSnapinImage)(HICON * hAppIcon);
  231. STDMETHOD(GetStaticFolderImage)(HBITMAP * hSmallImage,
  232. HBITMAP * hSmallImageOpen,
  233. HBITMAP * hLargeImage,
  234. COLORREF * cMask);
  235. //
  236. // Implemented ISnapinHelp interface members
  237. //
  238. public:
  239. STDMETHOD(GetHelpTopic)(LPOLESTR *lpCompiledHelpFile);
  240. // Notify handler declarations
  241. private:
  242. HRESULT OnAdd(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  243. HRESULT OnExpand(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  244. HRESULT OnSelect(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  245. HRESULT OnContextMenu(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  246. HRESULT OnProperties(LPARAM param);
  247. STDMETHOD(ChangePackageState)(CAppData & data, DWORD dwNewFlags, BOOL fShowUI);
  248. #if DBG==1
  249. public:
  250. int dbg_cRef;
  251. ULONG InternalAddRef()
  252. {
  253. ++dbg_cRef;
  254. // DebugMsg((DM_WARNING, TEXT("CScopePane::AddRef this=%08x ref=%u"), this, dbg_cRef));
  255. return CComObjectRoot::InternalAddRef();
  256. }
  257. ULONG InternalRelease()
  258. {
  259. --dbg_cRef;
  260. // DebugMsg((DM_WARNING, TEXT("CScopePane::Release this=%08x ref=%u"), this, dbg_cRef));
  261. return CComObjectRoot::InternalRelease();
  262. }
  263. #endif // DBG==1
  264. // Scope item creation helpers
  265. private:
  266. void DeleteList();
  267. void EnumerateScopePane(MMC_COOKIE cookie, HSCOPEITEM pParent);
  268. BOOL IsScopePaneNode(LPDATAOBJECT lpDataObject);
  269. HRESULT InitializeADE();
  270. HRESULT GetDeploymentType(PACKAGEDETAIL * ppd, BOOL & fShowPropertySheet);
  271. HRESULT DeployPackage(PACKAGEDETAIL * ppd, BOOL fShowPropertySheet);
  272. HRESULT AddZAPPackage(LPCOLESTR szPackagePath,
  273. LPCOLESTR lpFileTitle);
  274. HRESULT AddMSIPackage(LPCOLESTR szPackagePath,
  275. LPCOLESTR lpFileTitle);
  276. HRESULT RemovePackage(MMC_COOKIE cookie, BOOL fForceUninstall, BOOL fRemoveNow);
  277. void Refresh();
  278. HRESULT DetectUpgrades (LPCOLESTR szPackagePath, const PACKAGEDETAIL* ppd, CUpgrades& dlgUpgrade);
  279. HRESULT TestForRSoPData(BOOL * pfPolicyFailed);
  280. private:
  281. LPCONSOLENAMESPACE m_pScope; // My interface pointer to the scope pane
  282. LPCONSOLE m_pConsole;
  283. BOOL m_bIsDirty;
  284. IClassAdmin * m_pIClassAdmin;
  285. BOOL m_fExtension;
  286. BOOL m_fLoaded;
  287. void SetDirty(BOOL b = TRUE) { m_bIsDirty = b; }
  288. void ClearDirty() { m_bIsDirty = FALSE; }
  289. BOOL ThisIsDirty() { return m_bIsDirty; }
  290. void AddScopeItemToResultPane(MMC_COOKIE cookie);
  291. UINT CreateNestedDirectory (LPTSTR lpPath, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
  292. HRESULT GetClassStore(BOOL fCreateOK);
  293. void LoadToolDefaults();
  294. void SaveToolDefaults();
  295. set <CResultPane *> m_sResultPane;
  296. IPropertySheetProvider * m_pIPropertySheetProvider;
  297. BOOL m_fBlockAddPackage; // don't use a crit-sec
  298. // because all MMC UI is
  299. // always called from
  300. // the same thread
  301. public:
  302. void GetUniquePackageName(CString szIn, CString &szOut, int &nHint);
  303. HRESULT GetClassStoreName(CString &, BOOL fCreateOK);
  304. void DisplayPropSheet(CString szPackageName, int iPage);
  305. HRESULT PopulateUpgradeLists();
  306. HRESULT InsertUpgradeEntry(MMC_COOKIE cookie, CAppData &data);
  307. HRESULT RemoveUpgradeEntry(MMC_COOKIE cookie, CAppData &data);
  308. HRESULT PopulateExtensions();
  309. HRESULT InsertExtensionEntry(MMC_COOKIE cookie, CAppData &data);
  310. HRESULT RemoveExtensionEntry(MMC_COOKIE cookie, CAppData &data);
  311. HRESULT PrepareExtensions(PACKAGEDETAIL &pd);
  312. HRESULT ClearCategories();
  313. HRESULT GetPackageDSPath(CString &szPath, LPOLESTR szPackageName);
  314. HRESULT GetPackageNameFromUpgradeInfo(CString &szPackageName, GUID & PackageGuid, LPOLESTR szCSPath);
  315. HRESULT GetRSoPCategories(void);
  316. void CScopePane::RemoveResultPane(CResultPane * pRP);
  317. // global property pages
  318. CToolDefs * m_pToolDefs;
  319. CToolAdvDefs * m_pToolAdvDefs;
  320. CTracking * m_pTracking;
  321. CCatList * m_pCatList;
  322. CFileExt * m_pFileExt;
  323. #ifdef DIGITAL_SIGNATURES
  324. CSignatures * m_pSignatures;
  325. #endif // DIGITAL_SIGNATURES
  326. CString m_szGPT_Path;
  327. CString m_szGPO;
  328. CString m_szGPODisplayName;
  329. CString m_szDomainName;
  330. CString m_szLDAP_Path;
  331. CString m_szFolderTitle;
  332. CString m_szRSOPNamespace;
  333. map <MMC_COOKIE, CAppData> m_AppData; // One entry for each
  334. // application in the class
  335. // store. Maps cookies to
  336. // application packages.
  337. map <CString, EXTLIST> m_Extensions; // Maps extensions to the
  338. // list of apps that support
  339. // them.
  340. map <CString, MMC_COOKIE> m_UpgradeIndex; // Maps upgrade GUIDs to the
  341. // apps that they belong to.
  342. APPCATEGORYINFOLIST m_CatList; // category list
  343. TOOL_DEFAULTS m_ToolDefaults;
  344. BOOL m_fMachine;
  345. BOOL m_fRSOP;
  346. int m_iViewState;
  347. BOOL m_fDisplayedRsopARPWarning;
  348. MMC_COOKIE m_lLastAllocated;
  349. };
  350. class CMachineComponentDataImpl:
  351. public CScopePane,
  352. public CComCoClass<CMachineComponentDataImpl, &CLSID_MachineSnapin>
  353. {
  354. public:
  355. DECLARE_REGISTRY(CScopePane, _T("AppManager.1"), _T("AppManager"), IDS_SNAPIN_DESC, THREADFLAGS_BOTH)
  356. BEGIN_COM_MAP(CMachineComponentDataImpl)
  357. COM_INTERFACE_ENTRY(IComponentData)
  358. COM_INTERFACE_ENTRY(IExtendContextMenu)
  359. COM_INTERFACE_ENTRY(IPersistStreamInit)
  360. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  361. COM_INTERFACE_ENTRY(ISnapinAbout)
  362. COM_INTERFACE_ENTRY(ISnapinHelp)
  363. END_COM_MAP()
  364. CMachineComponentDataImpl()
  365. {
  366. m_fMachine = TRUE;
  367. m_fRSOP = FALSE;
  368. }
  369. virtual IUnknown * GetMyUnknown() {return GetUnknown();};
  370. };
  371. class CUserComponentDataImpl:
  372. public CScopePane,
  373. public CComCoClass<CUserComponentDataImpl, &CLSID_Snapin>
  374. {
  375. public:
  376. DECLARE_REGISTRY(CScopePane, _T("AppManager.1"), _T("AppManager"), IDS_SNAPIN_DESC, THREADFLAGS_BOTH)
  377. BEGIN_COM_MAP(CUserComponentDataImpl)
  378. COM_INTERFACE_ENTRY(IComponentData)
  379. COM_INTERFACE_ENTRY(IExtendContextMenu)
  380. COM_INTERFACE_ENTRY(IPersistStreamInit)
  381. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  382. COM_INTERFACE_ENTRY(ISnapinAbout)
  383. COM_INTERFACE_ENTRY(ISnapinHelp)
  384. END_COM_MAP()
  385. CUserComponentDataImpl()
  386. {
  387. m_fMachine = FALSE;
  388. m_fRSOP = FALSE;
  389. }
  390. virtual IUnknown * GetMyUnknown() {return GetUnknown();};
  391. };
  392. class CRSOPMachineComponentDataImpl:
  393. public CScopePane,
  394. public CComCoClass<CRSOPMachineComponentDataImpl, &CLSID_RSOP_MachineSnapin>
  395. {
  396. public:
  397. DECLARE_REGISTRY(CScopePane, _T("AppManager.1"), _T("AppManager"), IDS_SNAPIN_DESC, THREADFLAGS_BOTH)
  398. BEGIN_COM_MAP(CRSOPMachineComponentDataImpl)
  399. COM_INTERFACE_ENTRY(IComponentData)
  400. COM_INTERFACE_ENTRY(IExtendContextMenu)
  401. COM_INTERFACE_ENTRY(IPersistStreamInit)
  402. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  403. COM_INTERFACE_ENTRY(ISnapinAbout)
  404. COM_INTERFACE_ENTRY(ISnapinHelp)
  405. END_COM_MAP()
  406. CRSOPMachineComponentDataImpl()
  407. {
  408. m_fMachine = TRUE;
  409. m_fRSOP = TRUE;
  410. }
  411. virtual IUnknown * GetMyUnknown() {return GetUnknown();};
  412. };
  413. class CRSOPUserComponentDataImpl:
  414. public CScopePane,
  415. public CComCoClass<CRSOPUserComponentDataImpl, &CLSID_RSOP_Snapin>
  416. {
  417. public:
  418. DECLARE_REGISTRY(CScopePane, _T("AppManager.1"), _T("AppManager"), IDS_SNAPIN_DESC, THREADFLAGS_BOTH)
  419. BEGIN_COM_MAP(CRSOPUserComponentDataImpl)
  420. COM_INTERFACE_ENTRY(IComponentData)
  421. COM_INTERFACE_ENTRY(IExtendContextMenu)
  422. COM_INTERFACE_ENTRY(IPersistStreamInit)
  423. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  424. COM_INTERFACE_ENTRY(ISnapinAbout)
  425. COM_INTERFACE_ENTRY(ISnapinHelp)
  426. END_COM_MAP()
  427. CRSOPUserComponentDataImpl()
  428. {
  429. m_fMachine = FALSE;
  430. m_fRSOP = TRUE;
  431. }
  432. virtual IUnknown * GetMyUnknown() {return GetUnknown();};
  433. };
  434. class CResultPane :
  435. public IComponent,
  436. public IExtendContextMenu,
  437. public IExtendControlbar,
  438. public IExtendPropertySheet,
  439. public IResultDataCompare,
  440. public CComObjectRoot
  441. {
  442. public:
  443. BOOL _fVisible;
  444. CResultPane();
  445. ~CResultPane();
  446. BEGIN_COM_MAP(CResultPane)
  447. COM_INTERFACE_ENTRY(IComponent)
  448. COM_INTERFACE_ENTRY(IExtendContextMenu)
  449. COM_INTERFACE_ENTRY(IExtendControlbar)
  450. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  451. COM_INTERFACE_ENTRY(IResultDataCompare)
  452. END_COM_MAP()
  453. friend class CDataObject;
  454. static long lDataObjectRefCount;
  455. LPDISPLAYHELP m_pDisplayHelp;
  456. // IComponent interface members
  457. public:
  458. STDMETHOD(Initialize)(LPCONSOLE lpConsole);
  459. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  460. STDMETHOD(Destroy)(MMC_COOKIE cookie);
  461. STDMETHOD(GetResultViewType)(MMC_COOKIE cookie, BSTR* ppViewType, LONG * pViewOptions);
  462. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type,
  463. LPDATAOBJECT* ppDataObject);
  464. STDMETHOD(GetDisplayInfo)(RESULTDATAITEM* pResultDataItem);
  465. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  466. // IResultDataCompare
  467. STDMETHOD(Compare)(LPARAM lUserParam, MMC_COOKIE cookieA, MMC_COOKIE cookieB, int* pnResult);
  468. // IExtendControlbar
  469. STDMETHOD(SetControlbar)(LPCONTROLBAR pControlbar);
  470. STDMETHOD(ControlbarNotify)(MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  471. // IExtendPropertySheet interface
  472. public:
  473. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  474. LONG_PTR handle,
  475. LPDATAOBJECT lpIDataObject);
  476. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  477. // Helpers for CResultPane
  478. public:
  479. void SetIComponentData(CScopePane* pData);
  480. #if DBG==1
  481. public:
  482. int dbg_cRef;
  483. ULONG InternalAddRef()
  484. {
  485. ++dbg_cRef;
  486. // DebugMsg((DM_WARNING, TEXT("CResultPane::AddRef this=%08x ref=%u"), this, dbg_cRef));
  487. return CComObjectRoot::InternalAddRef();
  488. }
  489. ULONG InternalRelease()
  490. {
  491. --dbg_cRef;
  492. // DebugMsg((DM_WARNING, TEXT("CResultPane::Release this=%08x ref=%u"), this, dbg_cRef));
  493. return CComObjectRoot::InternalRelease();
  494. }
  495. #endif // DBG==1
  496. // Notify event handlers
  497. protected:
  498. HRESULT OnFolder(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  499. HRESULT OnShow(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  500. HRESULT OnActivate(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  501. HRESULT OnMinimize(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  502. HRESULT OnSelect(DATA_OBJECT_TYPES type, MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  503. HRESULT OnPropertyChange(LPARAM param);
  504. HRESULT OnUpdateView(LPDATAOBJECT lpDataObject);
  505. HRESULT OnResultItemClkOrDblClk(MMC_COOKIE cookie, BOOL fDblClick);
  506. BOOL OnFileDrop (LPDATAOBJECT lpDataObject);
  507. public:
  508. HRESULT OnAddImages(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  509. // IExtendContextMenu
  510. public:
  511. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pCallbackUnknown, LONG * pInsertionAllowed);
  512. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  513. // Helper functions
  514. protected:
  515. void Construct();
  516. HRESULT InitializeHeaders(MMC_COOKIE cookie);
  517. void Enumerate(MMC_COOKIE cookie, HSCOPEITEM pParent);
  518. public:
  519. void EnumerateResultPane(MMC_COOKIE cookie);
  520. HRESULT EnumerateRSoPData(void);
  521. // Interface pointers
  522. protected:
  523. LPCONSOLE m_pConsole; // Console's IFrame interface
  524. LPHEADERCTRL m_pHeader; // Result pane's header control interface
  525. CScopePane * m_pScopePane;
  526. LPCONSOLEVERB m_pConsoleVerb; // pointer the console verb
  527. LONG m_lViewMode; // View mode
  528. public:
  529. LPRESULTDATA m_pResult; // My interface pointer to the result pane
  530. LPTOOLBAR m_pToolbar;
  531. LPCONTROLBAR m_pControlbar;
  532. int m_nSortColumn;
  533. DWORD m_dwSortOptions;
  534. protected:
  535. // LPTOOLBAR m_pToolbar1; // Toolbar for view
  536. // LPTOOLBAR m_pToolbar2; // Toolbar for view
  537. // LPCONTROLBAR m_pControlbar; // control bar to hold my tool bars
  538. // CBitmap* m_pbmpToolbar1; // Imagelist for the first toolbar
  539. // CBitmap* m_pbmpToolbar2; // Imagelist for the first toolbar
  540. // Header titles for each nodetype(s)
  541. protected:
  542. CString m_szFolderTitle;
  543. };
  544. inline void CResultPane::SetIComponentData(CScopePane* pData)
  545. {
  546. ASSERT(pData);
  547. DebugMsg((DM_VERBOSE, TEXT("CResultPane::SetIComponentData pData=%08x."), pData));
  548. ASSERT(m_pScopePane == NULL);
  549. LPUNKNOWN pUnk = pData->GetMyUnknown();
  550. pUnk->AddRef();
  551. #if 0
  552. HRESULT hr;
  553. LPCOMPONENTDATA lpcd;
  554. hr = pUnk->QueryInterface(IID_IComponentData, reinterpret_cast<void**>(&lpcd));
  555. ASSERT(hr == S_OK);
  556. if (SUCCEEDED(hr))
  557. {
  558. m_pScopePane = dynamic_cast<CScopePane*>(lpcd);
  559. }
  560. #else
  561. m_pScopePane = pData;
  562. #endif
  563. }
  564. #define FREE_INTERNAL(pInternal) \
  565. ASSERT(pInternal != NULL); \
  566. do { if (pInternal != NULL) \
  567. GlobalFree(pInternal); } \
  568. while(0);
  569. class CHourglass
  570. {
  571. private:
  572. HCURSOR m_hcurSaved;
  573. public:
  574. CHourglass()
  575. {
  576. m_hcurSaved = ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT)));
  577. };
  578. ~CHourglass()
  579. {
  580. ::SetCursor(m_hcurSaved);
  581. };
  582. };
  583. class CUpgradeData
  584. {
  585. public:
  586. GUID m_PackageGuid;
  587. CString m_szClassStore;
  588. int m_flags;
  589. };
  590. LRESULT SetPropPageToDeleteOnClose(void * vpsp);
  591. CString GetUpgradeIndex(GUID & PackageID);
  592. #define HELP_FILE TEXT("ade.hlp")
  593. void LogADEEvent(WORD wType, DWORD dwEventID, HRESULT hr, LPCWSTR szOptional = NULL);
  594. void ReportGeneralPropertySheetError(HWND hwnd, LPCWSTR sz, HRESULT hr);
  595. void ReportPolicyChangedError(HWND hwnd);
  596. void WINAPI StandardHelp(HWND hWnd, UINT nIDD, BOOL fRsop = FALSE);
  597. void WINAPI StandardContextMenu(HWND hWnd, UINT nIDD, BOOL fRsop = FALSE);
  598. #define ATOW(wsz, sz, cch) MultiByteToWideChar(CP_ACP, 0, sz, -1, wsz, cch)
  599. #define WTOA(sz, wsz, cch) WideCharToMultiByte(CP_ACP, 0, wsz, -1, sz, cch, NULL, NULL)
  600. #define ATOWLEN(sz) MultiByteToWideChar(CP_ACP, 0, sz, -1, NULL, 0)
  601. #define WTOALEN(wsz) WideCharToMultiByte(CP_ACP, 0, wsz, -1, NULL, 0, NULL, NULL)
  602. //
  603. // Helper function and defines for theme'ing property pages put up by the snap-in.
  604. //
  605. #ifdef UNICODE
  606. #define PROPSHEETPAGE_V3 PROPSHEETPAGEW_V3
  607. #else
  608. #define PROPSHEETPAGE_V3 PROPSHEETPAGEA_V3
  609. #endif
  610. HPROPSHEETPAGE CreateThemedPropertySheetPage(AFX_OLDPROPSHEETPAGE* psp);