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.

155 lines
5.2 KiB

  1. /////////////////////////////////////////////////////////////////////
  2. // compdata.h : Declaration of CMyComputerComponentData
  3. //
  4. // HISTORY
  5. // 01-Jan-1996 ??? Creation
  6. // 03-Jun-1997 t-danm Added Command Line override. Copied
  7. // from ..\mmcfmgmt\compdata.h.
  8. //
  9. /////////////////////////////////////////////////////////////////////
  10. #ifndef __COMPDATA_H_INCLUDED__
  11. #define __COMPDATA_H_INCLUDED__
  12. #include <lmcons.h> // For Lan Manager API constants.
  13. #include "stdcdata.h" // CComponentData
  14. #include "persist.h" // PersistStream
  15. #include "cookie.h" // CMyComputerCookie
  16. #include "resource.h" // IDS_MYCOMPUT_DESC
  17. #include "cmponent.h" // LoadIconsIntoImageList
  18. // Helper function to correctly format the node name
  19. CString FormatDisplayName (CString machineName);
  20. // For UpdateAllViews/OnViewChange
  21. #define HINT_SELECT_ROOT_NODE 0x00000001
  22. class CMyComputerComponentData:
  23. public CComponentData,
  24. public IExtendPropertySheet,
  25. public PersistStream,
  26. public CHasMachineName,
  27. public IExtendContextMenu,
  28. public CComCoClass<CMyComputerComponentData, &CLSID_MyComputer>
  29. {
  30. public:
  31. // Use DECLARE_NOT_AGGREGATABLE(CMyComputerComponentData)
  32. // if you don't want your object to support aggregation
  33. DECLARE_AGGREGATABLE(CMyComputerComponentData)
  34. DECLARE_REGISTRY(CMyComputerComponentData, _T("MYCOMPUT.ComputerObject.1"), _T("MYCOMPUT.ComputerObject.1"), IDS_MYCOMPUT_DESC, THREADFLAGS_BOTH)
  35. CMyComputerComponentData();
  36. ~CMyComputerComponentData();
  37. BEGIN_COM_MAP(CMyComputerComponentData)
  38. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  39. COM_INTERFACE_ENTRY(IPersistStream)
  40. COM_INTERFACE_ENTRY(IExtendContextMenu)
  41. COM_INTERFACE_ENTRY_CHAIN(CComponentData)
  42. END_COM_MAP()
  43. #if DBG==1
  44. ULONG InternalAddRef()
  45. {
  46. return CComObjectRoot::InternalAddRef();
  47. }
  48. ULONG InternalRelease()
  49. {
  50. return CComObjectRoot::InternalRelease();
  51. }
  52. int dbg_InstID;
  53. #endif // DBG==1
  54. // IComponentData
  55. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  56. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  57. // IExtendPropertySheet
  58. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK pCall, LONG_PTR handle, LPDATAOBJECT pDataObject);
  59. STDMETHOD(QueryPagesFor)(LPDATAOBJECT pDataObject);
  60. // IPersistStream
  61. HRESULT STDMETHODCALLTYPE GetClassID(CLSID __RPC_FAR *pClassID)
  62. {
  63. *pClassID=CLSID_MyComputer;
  64. return S_OK;
  65. }
  66. HRESULT STDMETHODCALLTYPE Load(IStream __RPC_FAR *pStg);
  67. HRESULT STDMETHODCALLTYPE Save(IStream __RPC_FAR *pStgSave, BOOL fSameAsLoad);
  68. // needed for Initialize()
  69. virtual HRESULT LoadIcons(LPIMAGELIST pImageList, BOOL fLoadLargeIcons);
  70. // needed for Notify()
  71. virtual HRESULT OnNotifyExpand(LPDATAOBJECT lpDataObject, BOOL bExpanding, HSCOPEITEM hParent);
  72. HRESULT ExpandServerApps( HSCOPEITEM hParent, CMyComputerCookie* pcookie );
  73. // needed for GetDisplayInfo(), must be defined by subclass
  74. virtual BSTR QueryResultColumnText(CCookie& basecookieref, int nCol );
  75. virtual int QueryImage(CCookie& basecookieref, BOOL fOpenImage);
  76. virtual CCookie& QueryBaseRootCookie();
  77. inline CMyComputerCookie* ActiveCookie( CCookie* pBaseCookie )
  78. {
  79. return (CMyComputerCookie*)ActiveBaseCookie( pBaseCookie );
  80. }
  81. inline CMyComputerCookie& QueryRootCookie() { return *m_pRootCookie; }
  82. virtual HRESULT OnNotifyDelete(LPDATAOBJECT lpDataObject);
  83. virtual HRESULT OnNotifyRelease(LPDATAOBJECT lpDataObject, HSCOPEITEM hItem);
  84. virtual HRESULT OnNotifyPreload(LPDATAOBJECT lpDataObject, HSCOPEITEM hRootScopeItem);
  85. // CHasMachineName
  86. DECLARE_FORWARDS_MACHINE_NAME( m_pRootCookie )
  87. bool m_bCannotConnect;
  88. bool m_bMessageView;
  89. CString m_strMessageViewMsg;
  90. protected:
  91. bool ValidateMachine(const CString &sName, bool bDisplayErr);
  92. HRESULT AddScopeNodes (HSCOPEITEM hParent, CMyComputerCookie& rParentCookie);
  93. HRESULT ChangeRootNodeName (const CString& newName);
  94. HRESULT OnChangeComputer (IDataObject* piDataObject);
  95. // The following members are used to support Command Line override.
  96. // This code was copied from ..\mmcfmgmt\compdata.h.
  97. enum // Bit fields for m_dwFlagsPersist
  98. {
  99. mskfAllowOverrideMachineName = 0x0001
  100. };
  101. DWORD m_dwFlagsPersist; // General-purpose flags to be persisted into .msc file
  102. CString m_strMachineNamePersist; // Machine name to persist into .msc file
  103. BOOL m_fAllowOverrideMachineName; // TRUE => Allow the machine name to be overriden by the command line
  104. void SetPersistentFlags(DWORD dwFlags)
  105. {
  106. m_dwFlagsPersist = dwFlags;
  107. m_fAllowOverrideMachineName = !!(m_dwFlagsPersist & mskfAllowOverrideMachineName);
  108. }
  109. DWORD GetPersistentFlags()
  110. {
  111. if (m_fAllowOverrideMachineName)
  112. m_dwFlagsPersist |= mskfAllowOverrideMachineName;
  113. else
  114. m_dwFlagsPersist &= ~mskfAllowOverrideMachineName;
  115. return m_dwFlagsPersist;
  116. }
  117. // IExtendContextMenu
  118. STDMETHOD(AddMenuItems)(
  119. IDataObject* piDataObject,
  120. IContextMenuCallback* piCallback,
  121. long* pInsertionAllowed);
  122. STDMETHOD(Command)(
  123. LONG lCommandID,
  124. IDataObject* piDataObject );
  125. private:
  126. CMyComputerCookie* m_pRootCookie;
  127. }; // CMyComputerComponentData
  128. #endif // ~__COMPDATA_H_INCLUDED__