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.

716 lines
24 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); \
  123. szO=(OLECHAR *)OLEALLOC(sizeof(OLECHAR) * (i_dontcollidewithanything+1));\
  124. if (szO) {HRESULT hrSafeCopy = StringCchCopy(szO, i_dontcollidewithanything+1, szI);ASSERT(SUCCEEDED(hrSafeCopy));}} else szO=NULL;}
  125. // Keys used in the CFG file.
  126. //
  127. // The CFG file is found in the Applications directory of the SysVol (which
  128. // is the same directory as the script files).
  129. //
  130. // The format of an entry in the CFG file is:
  131. //
  132. // %key%=%data%
  133. //
  134. // where %data% is either an integer or a string as appropriate.
  135. //
  136. // Order is not important and if a key is not present in the CFG file then
  137. // the default setting will be used. Some keys (iDebugLevel and
  138. // fShowPkgDetails) will only be saved in the CFG file if their values are
  139. // different from the default settings.
  140. //
  141. #define KEY_NPBehavior L"Default Deployment"
  142. #define KEY_fCustomDeployment L"Use Custom Deployment"
  143. #define KEY_fUseWizard L"Use Deployment Wizard"
  144. #define KEY_UILevel L"UI Level"
  145. #define KEY_szStartPath L"Start Path"
  146. #define KEY_iDebugLevel L"Debug Level"
  147. #define KEY_fShowPkgDetails L"Package Details"
  148. #define KEY_f32On64 L"Run 32b Apps on 64b"
  149. #define KEY_fZapOn64 L"Run ZAP Apps on 64b"
  150. #define KEY_fExtensionsOnly L"Only Deploy Extension Info"
  151. #define KEY_nUninstallTrackingMonths L"Uninstall Tracking Months"
  152. #define KEY_fUninstallOnPolicyRemoval L"Uninstall On Policy Removal"
  153. typedef struct tagTOOL_DEFAULTS
  154. {
  155. NEW_PACKAGE_BEHAVIOR NPBehavior;
  156. BOOL fCustomDeployment;
  157. BOOL fUseWizard;
  158. INSTALLUILEVEL UILevel;
  159. CString szStartPath;
  160. int iDebugLevel;
  161. BOOL fShowPkgDetails;
  162. ULONG nUninstallTrackingMonths;
  163. BOOL fUninstallOnPolicyRemoval;
  164. BOOL fZapOn64;
  165. BOOL f32On64;
  166. BOOL fExtensionsOnly;
  167. } TOOL_DEFAULTS;
  168. /////////////////////////////////////////////////////////////////////////////
  169. // Snapin
  170. typedef set<long> EXTLIST;
  171. INTERNAL* ExtractInternalFormat(LPDATAOBJECT lpDataObject);
  172. class CToolDefs;
  173. class CToolAdvDefs;
  174. class CTracking;
  175. class CCatList;
  176. class CFileExt;
  177. class CSignatures;
  178. class CScopePane:
  179. public IComponentData,
  180. public IExtendContextMenu,
  181. public IPersistStreamInit,
  182. public IExtendPropertySheet,
  183. public ISnapinAbout,
  184. public ISnapinHelp,
  185. public CComObjectRoot
  186. {
  187. friend class CResultPane;
  188. friend class CDataObject;
  189. public:
  190. CScopePane();
  191. ~CScopePane();
  192. HWND m_hwndMainWindow;
  193. LPRSOPINFORMATION m_pIRSOPInformation; // Interface pointer to the GPT
  194. protected:
  195. LPGPEINFORMATION m_pIGPEInformation; // Interface pointer to the GPT
  196. BOOL m_fRSOPEnumerate; // OK to enumerate RSoP data
  197. BOOL m_fRSOPPolicyFailed; // TRUE if there was a failure applying SI policy
  198. public:
  199. DWORD m_dwRSOPFlags;
  200. virtual IUnknown * GetMyUnknown() = 0;
  201. // IComponentData interface members
  202. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  203. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  204. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  205. STDMETHOD(Destroy)();
  206. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  207. STDMETHOD(GetDisplayInfo)(SCOPEDATAITEM* pScopeDataItem);
  208. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  209. // IExtendContextMenu
  210. public:
  211. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pCallbackUnknown, LONG * pInsertionAllowed);
  212. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  213. public:
  214. // IPersistStreamInit interface members
  215. STDMETHOD(GetClassID)(CLSID *pClassID);
  216. STDMETHOD(IsDirty)();
  217. STDMETHOD(Load)(IStream *pStm);
  218. STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty);
  219. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
  220. STDMETHOD(InitNew)(VOID);
  221. // IExtendPropertySheet interface
  222. public:
  223. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  224. LONG_PTR handle,
  225. LPDATAOBJECT lpIDataObject);
  226. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  227. // ISnapinAbout interface
  228. public:
  229. STDMETHOD(GetSnapinDescription)(LPOLESTR * lpDescription);
  230. STDMETHOD(GetProvider)(LPOLESTR * lpName);
  231. STDMETHOD(GetSnapinVersion)(LPOLESTR * lpVersion);
  232. STDMETHOD(GetSnapinImage)(HICON * hAppIcon);
  233. STDMETHOD(GetStaticFolderImage)(HBITMAP * hSmallImage,
  234. HBITMAP * hSmallImageOpen,
  235. HBITMAP * hLargeImage,
  236. COLORREF * cMask);
  237. //
  238. // Implemented ISnapinHelp interface members
  239. //
  240. public:
  241. STDMETHOD(GetHelpTopic)(LPOLESTR *lpCompiledHelpFile);
  242. // Notify handler declarations
  243. private:
  244. HRESULT OnAdd(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  245. HRESULT OnExpand(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  246. HRESULT OnSelect(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  247. HRESULT OnContextMenu(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  248. HRESULT OnProperties(LPARAM param);
  249. STDMETHOD(ChangePackageState)(CAppData & data, DWORD dwNewFlags, BOOL fShowUI);
  250. #if DBG==1
  251. public:
  252. int dbg_cRef;
  253. ULONG InternalAddRef()
  254. {
  255. ++dbg_cRef;
  256. // DebugMsg((DM_WARNING, TEXT("CScopePane::AddRef this=%08x ref=%u"), this, dbg_cRef));
  257. return CComObjectRoot::InternalAddRef();
  258. }
  259. ULONG InternalRelease()
  260. {
  261. --dbg_cRef;
  262. // DebugMsg((DM_WARNING, TEXT("CScopePane::Release this=%08x ref=%u"), this, dbg_cRef));
  263. return CComObjectRoot::InternalRelease();
  264. }
  265. #endif // DBG==1
  266. // Scope item creation helpers
  267. private:
  268. void DeleteList();
  269. void EnumerateScopePane(MMC_COOKIE cookie, HSCOPEITEM pParent);
  270. BOOL IsScopePaneNode(LPDATAOBJECT lpDataObject);
  271. HRESULT InitializeADE();
  272. HRESULT GetDeploymentType(PACKAGEDETAIL * ppd, BOOL & fShowPropertySheet);
  273. HRESULT DeployPackage(PACKAGEDETAIL * ppd, BOOL fShowPropertySheet);
  274. HRESULT AddZAPPackage(LPCOLESTR szPackagePath,
  275. LPCOLESTR lpFileTitle);
  276. HRESULT AddMSIPackage(LPCOLESTR szPackagePath,
  277. LPCOLESTR lpFileTitle);
  278. HRESULT RemovePackage(MMC_COOKIE cookie, BOOL fForceUninstall, BOOL fRemoveNow);
  279. void Refresh();
  280. HRESULT DetectUpgrades (LPCOLESTR szPackagePath, const PACKAGEDETAIL* ppd, CUpgrades& dlgUpgrade);
  281. HRESULT TestForRSoPData(BOOL * pfPolicyFailed);
  282. private:
  283. LPCONSOLENAMESPACE m_pScope; // My interface pointer to the scope pane
  284. LPCONSOLE m_pConsole;
  285. BOOL m_bIsDirty;
  286. IClassAdmin * m_pIClassAdmin;
  287. BOOL m_fExtension;
  288. BOOL m_fLoaded;
  289. void SetDirty(BOOL b = TRUE) { m_bIsDirty = b; }
  290. void ClearDirty() { m_bIsDirty = FALSE; }
  291. BOOL ThisIsDirty() { return m_bIsDirty; }
  292. void AddScopeItemToResultPane(MMC_COOKIE cookie);
  293. UINT CreateNestedDirectory (LPTSTR lpPath, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
  294. HRESULT GetClassStore(BOOL fCreateOK);
  295. void LoadToolDefaults();
  296. void SaveToolDefaults();
  297. set <CResultPane *> m_sResultPane;
  298. IPropertySheetProvider * m_pIPropertySheetProvider;
  299. BOOL m_fBlockAddPackage; // don't use a crit-sec
  300. // because all MMC UI is
  301. // always called from
  302. // the same thread
  303. public:
  304. void GetUniquePackageName(CString szIn, CString &szOut, int &nHint);
  305. HRESULT GetClassStoreName(CString &, BOOL fCreateOK);
  306. void DisplayPropSheet(CString szPackageName, int iPage);
  307. HRESULT PopulateUpgradeLists();
  308. HRESULT InsertUpgradeEntry(MMC_COOKIE cookie, CAppData &data);
  309. HRESULT RemoveUpgradeEntry(MMC_COOKIE cookie, CAppData &data);
  310. HRESULT PopulateExtensions();
  311. HRESULT InsertExtensionEntry(MMC_COOKIE cookie, CAppData &data);
  312. HRESULT RemoveExtensionEntry(MMC_COOKIE cookie, CAppData &data);
  313. HRESULT PrepareExtensions(PACKAGEDETAIL &pd);
  314. HRESULT ClearCategories();
  315. HRESULT GetPackageDSPath(CString &szPath, LPOLESTR szPackageName);
  316. HRESULT GetPackageNameFromUpgradeInfo(CString &szPackageName, GUID & PackageGuid, LPOLESTR szCSPath);
  317. HRESULT GetRSoPCategories(void);
  318. void CScopePane::RemoveResultPane(CResultPane * pRP);
  319. // global property pages
  320. CToolDefs * m_pToolDefs;
  321. CToolAdvDefs * m_pToolAdvDefs;
  322. CTracking * m_pTracking;
  323. CCatList * m_pCatList;
  324. CFileExt * m_pFileExt;
  325. #ifdef DIGITAL_SIGNATURES
  326. CSignatures * m_pSignatures;
  327. #endif // DIGITAL_SIGNATURES
  328. CString m_szGPT_Path;
  329. CString m_szGPO;
  330. CString m_szGPODisplayName;
  331. CString m_szDomainName;
  332. CString m_szLDAP_Path;
  333. CString m_szFolderTitle;
  334. CString m_szRSOPNamespace;
  335. map <MMC_COOKIE, CAppData> m_AppData; // One entry for each
  336. // application in the class
  337. // store. Maps cookies to
  338. // application packages.
  339. map <CString, EXTLIST> m_Extensions; // Maps extensions to the
  340. // list of apps that support
  341. // them.
  342. map <CString, MMC_COOKIE> m_UpgradeIndex; // Maps upgrade GUIDs to the
  343. // apps that they belong to.
  344. APPCATEGORYINFOLIST m_CatList; // category list
  345. TOOL_DEFAULTS m_ToolDefaults;
  346. BOOL m_fMachine;
  347. BOOL m_fRSOP;
  348. int m_iViewState;
  349. BOOL m_fDisplayedRsopARPWarning;
  350. MMC_COOKIE m_lLastAllocated;
  351. };
  352. class CMachineComponentDataImpl:
  353. public CScopePane,
  354. public CComCoClass<CMachineComponentDataImpl, &CLSID_MachineSnapin>
  355. {
  356. public:
  357. DECLARE_REGISTRY(CScopePane, _T("AppManager.1"), _T("AppManager"), IDS_SNAPIN_DESC, THREADFLAGS_BOTH)
  358. BEGIN_COM_MAP(CMachineComponentDataImpl)
  359. COM_INTERFACE_ENTRY(IComponentData)
  360. COM_INTERFACE_ENTRY(IExtendContextMenu)
  361. COM_INTERFACE_ENTRY(IPersistStreamInit)
  362. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  363. COM_INTERFACE_ENTRY(ISnapinAbout)
  364. COM_INTERFACE_ENTRY(ISnapinHelp)
  365. END_COM_MAP()
  366. CMachineComponentDataImpl()
  367. {
  368. m_fMachine = TRUE;
  369. m_fRSOP = FALSE;
  370. }
  371. virtual IUnknown * GetMyUnknown() {return GetUnknown();};
  372. };
  373. class CUserComponentDataImpl:
  374. public CScopePane,
  375. public CComCoClass<CUserComponentDataImpl, &CLSID_Snapin>
  376. {
  377. public:
  378. DECLARE_REGISTRY(CScopePane, _T("AppManager.1"), _T("AppManager"), IDS_SNAPIN_DESC, THREADFLAGS_BOTH)
  379. BEGIN_COM_MAP(CUserComponentDataImpl)
  380. COM_INTERFACE_ENTRY(IComponentData)
  381. COM_INTERFACE_ENTRY(IExtendContextMenu)
  382. COM_INTERFACE_ENTRY(IPersistStreamInit)
  383. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  384. COM_INTERFACE_ENTRY(ISnapinAbout)
  385. COM_INTERFACE_ENTRY(ISnapinHelp)
  386. END_COM_MAP()
  387. CUserComponentDataImpl()
  388. {
  389. m_fMachine = FALSE;
  390. m_fRSOP = FALSE;
  391. }
  392. virtual IUnknown * GetMyUnknown() {return GetUnknown();};
  393. };
  394. class CRSOPMachineComponentDataImpl:
  395. public CScopePane,
  396. public CComCoClass<CRSOPMachineComponentDataImpl, &CLSID_RSOP_MachineSnapin>
  397. {
  398. public:
  399. DECLARE_REGISTRY(CScopePane, _T("AppManager.1"), _T("AppManager"), IDS_SNAPIN_DESC, THREADFLAGS_BOTH)
  400. BEGIN_COM_MAP(CRSOPMachineComponentDataImpl)
  401. COM_INTERFACE_ENTRY(IComponentData)
  402. COM_INTERFACE_ENTRY(IExtendContextMenu)
  403. COM_INTERFACE_ENTRY(IPersistStreamInit)
  404. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  405. COM_INTERFACE_ENTRY(ISnapinAbout)
  406. COM_INTERFACE_ENTRY(ISnapinHelp)
  407. END_COM_MAP()
  408. CRSOPMachineComponentDataImpl()
  409. {
  410. m_fMachine = TRUE;
  411. m_fRSOP = TRUE;
  412. }
  413. virtual IUnknown * GetMyUnknown() {return GetUnknown();};
  414. };
  415. class CRSOPUserComponentDataImpl:
  416. public CScopePane,
  417. public CComCoClass<CRSOPUserComponentDataImpl, &CLSID_RSOP_Snapin>
  418. {
  419. public:
  420. DECLARE_REGISTRY(CScopePane, _T("AppManager.1"), _T("AppManager"), IDS_SNAPIN_DESC, THREADFLAGS_BOTH)
  421. BEGIN_COM_MAP(CRSOPUserComponentDataImpl)
  422. COM_INTERFACE_ENTRY(IComponentData)
  423. COM_INTERFACE_ENTRY(IExtendContextMenu)
  424. COM_INTERFACE_ENTRY(IPersistStreamInit)
  425. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  426. COM_INTERFACE_ENTRY(ISnapinAbout)
  427. COM_INTERFACE_ENTRY(ISnapinHelp)
  428. END_COM_MAP()
  429. CRSOPUserComponentDataImpl()
  430. {
  431. m_fMachine = FALSE;
  432. m_fRSOP = TRUE;
  433. }
  434. virtual IUnknown * GetMyUnknown() {return GetUnknown();};
  435. };
  436. class CResultPane :
  437. public IComponent,
  438. public IExtendContextMenu,
  439. public IExtendControlbar,
  440. public IExtendPropertySheet,
  441. public IResultDataCompare,
  442. public CComObjectRoot
  443. {
  444. public:
  445. BOOL _fVisible;
  446. CResultPane();
  447. ~CResultPane();
  448. BEGIN_COM_MAP(CResultPane)
  449. COM_INTERFACE_ENTRY(IComponent)
  450. COM_INTERFACE_ENTRY(IExtendContextMenu)
  451. COM_INTERFACE_ENTRY(IExtendControlbar)
  452. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  453. COM_INTERFACE_ENTRY(IResultDataCompare)
  454. END_COM_MAP()
  455. friend class CDataObject;
  456. static long lDataObjectRefCount;
  457. LPDISPLAYHELP m_pDisplayHelp;
  458. // IComponent interface members
  459. public:
  460. STDMETHOD(Initialize)(LPCONSOLE lpConsole);
  461. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  462. STDMETHOD(Destroy)(MMC_COOKIE cookie);
  463. STDMETHOD(GetResultViewType)(MMC_COOKIE cookie, BSTR* ppViewType, LONG * pViewOptions);
  464. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type,
  465. LPDATAOBJECT* ppDataObject);
  466. STDMETHOD(GetDisplayInfo)(RESULTDATAITEM* pResultDataItem);
  467. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  468. // IResultDataCompare
  469. STDMETHOD(Compare)(LPARAM lUserParam, MMC_COOKIE cookieA, MMC_COOKIE cookieB, int* pnResult);
  470. // IExtendControlbar
  471. STDMETHOD(SetControlbar)(LPCONTROLBAR pControlbar);
  472. STDMETHOD(ControlbarNotify)(MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  473. // IExtendPropertySheet interface
  474. public:
  475. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  476. LONG_PTR handle,
  477. LPDATAOBJECT lpIDataObject);
  478. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  479. // Helpers for CResultPane
  480. public:
  481. void SetIComponentData(CScopePane* pData);
  482. #if DBG==1
  483. public:
  484. int dbg_cRef;
  485. ULONG InternalAddRef()
  486. {
  487. ++dbg_cRef;
  488. // DebugMsg((DM_WARNING, TEXT("CResultPane::AddRef this=%08x ref=%u"), this, dbg_cRef));
  489. return CComObjectRoot::InternalAddRef();
  490. }
  491. ULONG InternalRelease()
  492. {
  493. --dbg_cRef;
  494. // DebugMsg((DM_WARNING, TEXT("CResultPane::Release this=%08x ref=%u"), this, dbg_cRef));
  495. return CComObjectRoot::InternalRelease();
  496. }
  497. #endif // DBG==1
  498. // Notify event handlers
  499. protected:
  500. HRESULT OnFolder(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  501. HRESULT OnShow(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  502. HRESULT OnActivate(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  503. HRESULT OnMinimize(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  504. HRESULT OnSelect(DATA_OBJECT_TYPES type, MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  505. HRESULT OnPropertyChange(LPARAM param);
  506. HRESULT OnUpdateView(LPDATAOBJECT lpDataObject);
  507. HRESULT OnResultItemClkOrDblClk(MMC_COOKIE cookie, BOOL fDblClick);
  508. BOOL OnFileDrop (LPDATAOBJECT lpDataObject);
  509. public:
  510. HRESULT OnAddImages(MMC_COOKIE cookie, LPARAM arg, LPARAM param);
  511. // IExtendContextMenu
  512. public:
  513. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pCallbackUnknown, LONG * pInsertionAllowed);
  514. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  515. // Helper functions
  516. protected:
  517. void Construct();
  518. HRESULT InitializeHeaders(MMC_COOKIE cookie);
  519. void Enumerate(MMC_COOKIE cookie, HSCOPEITEM pParent);
  520. public:
  521. void EnumerateResultPane(MMC_COOKIE cookie);
  522. HRESULT EnumerateRSoPData(void);
  523. // Interface pointers
  524. protected:
  525. LPCONSOLE m_pConsole; // Console's IFrame interface
  526. LPHEADERCTRL m_pHeader; // Result pane's header control interface
  527. CScopePane * m_pScopePane;
  528. LPCONSOLEVERB m_pConsoleVerb; // pointer the console verb
  529. LONG m_lViewMode; // View mode
  530. public:
  531. LPRESULTDATA m_pResult; // My interface pointer to the result pane
  532. LPTOOLBAR m_pToolbar;
  533. LPCONTROLBAR m_pControlbar;
  534. int m_nSortColumn;
  535. DWORD m_dwSortOptions;
  536. protected:
  537. // LPTOOLBAR m_pToolbar1; // Toolbar for view
  538. // LPTOOLBAR m_pToolbar2; // Toolbar for view
  539. // LPCONTROLBAR m_pControlbar; // control bar to hold my tool bars
  540. // CBitmap* m_pbmpToolbar1; // Imagelist for the first toolbar
  541. // CBitmap* m_pbmpToolbar2; // Imagelist for the first toolbar
  542. // Header titles for each nodetype(s)
  543. protected:
  544. CString m_szFolderTitle;
  545. };
  546. inline void CResultPane::SetIComponentData(CScopePane* pData)
  547. {
  548. ASSERT(pData);
  549. DebugMsg((DM_VERBOSE, TEXT("CResultPane::SetIComponentData pData=%08x."), pData));
  550. ASSERT(m_pScopePane == NULL);
  551. LPUNKNOWN pUnk = pData->GetMyUnknown();
  552. pUnk->AddRef();
  553. #if 0
  554. HRESULT hr;
  555. LPCOMPONENTDATA lpcd;
  556. hr = pUnk->QueryInterface(IID_IComponentData, reinterpret_cast<void**>(&lpcd));
  557. ASSERT(hr == S_OK);
  558. if (SUCCEEDED(hr))
  559. {
  560. m_pScopePane = dynamic_cast<CScopePane*>(lpcd);
  561. }
  562. #else
  563. m_pScopePane = pData;
  564. #endif
  565. }
  566. #define FREE_INTERNAL(pInternal) \
  567. ASSERT(pInternal != NULL); \
  568. do { if (pInternal != NULL) \
  569. GlobalFree(pInternal); } \
  570. while(0);
  571. class CHourglass
  572. {
  573. private:
  574. HCURSOR m_hcurSaved;
  575. public:
  576. CHourglass()
  577. {
  578. m_hcurSaved = ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT)));
  579. };
  580. ~CHourglass()
  581. {
  582. ::SetCursor(m_hcurSaved);
  583. };
  584. };
  585. class CUpgradeData
  586. {
  587. public:
  588. GUID m_PackageGuid;
  589. CString m_szClassStore;
  590. int m_flags;
  591. };
  592. LRESULT SetPropPageToDeleteOnClose(void * vpsp);
  593. CString GetUpgradeIndex(GUID & PackageID);
  594. #define HELP_FILE TEXT("ade.hlp")
  595. void LogADEEvent(WORD wType, DWORD dwEventID, HRESULT hr, LPCWSTR szOptional = NULL);
  596. void ReportGeneralPropertySheetError(HWND hwnd, LPCWSTR sz, HRESULT hr);
  597. void ReportPolicyChangedError(HWND hwnd);
  598. void WINAPI StandardHelp(HWND hWnd, UINT nIDD, BOOL fRsop = FALSE);
  599. void WINAPI StandardContextMenu(HWND hWnd, UINT nIDD, BOOL fRsop = FALSE);
  600. #define ATOW(wsz, sz, cch) MultiByteToWideChar(CP_ACP, 0, sz, -1, wsz, cch)
  601. #define WTOA(sz, wsz, cch) WideCharToMultiByte(CP_ACP, 0, wsz, -1, sz, cch, NULL, NULL)
  602. #define ATOWLEN(sz) MultiByteToWideChar(CP_ACP, 0, sz, -1, NULL, 0)
  603. #define WTOALEN(wsz) WideCharToMultiByte(CP_ACP, 0, wsz, -1, NULL, 0, NULL, NULL)
  604. //
  605. // Helper function and defines for theme'ing property pages put up by the snap-in.
  606. //
  607. #ifdef UNICODE
  608. #define PROPSHEETPAGE_V3 PROPSHEETPAGEW_V3
  609. #else
  610. #define PROPSHEETPAGE_V3 PROPSHEETPAGEA_V3
  611. #endif
  612. HPROPSHEETPAGE CreateThemedPropertySheetPage(AFX_OLDPROPSHEETPAGE* psp);