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.

415 lines
12 KiB

  1. //
  2. // GPE Script SnapIn extension GUIDs
  3. //
  4. // {40B6664F-4972-11d1-A7CA-0000F87571E3}
  5. DEFINE_GUID(CLSID_ScriptSnapInMachine,0x40b6664f, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  6. // {40B66650-4972-11d1-A7CA-0000F87571E3}
  7. DEFINE_GUID(CLSID_ScriptSnapInUser,0x40b66650, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  8. //
  9. // GPE Script node ids
  10. //
  11. // {40B66651-4972-11d1-A7CA-0000F87571E3}
  12. DEFINE_GUID(NODEID_ScriptRootMachine,0x40b66651, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  13. // {40B66652-4972-11d1-A7CA-0000F87571E3}
  14. DEFINE_GUID(NODEID_ScriptRootUser,0x40b66652, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  15. // {40B66653-4972-11d1-A7CA-0000F87571E3}
  16. DEFINE_GUID(NODEID_ScriptRoot,0x40b66653, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  17. //
  18. // RSOP Script SnapIn extension GUIDs
  19. //
  20. // {40B66660-4972-11d1-A7CA-0000F87571E3}
  21. DEFINE_GUID(CLSID_RSOPScriptSnapInMachine,0x40b66660, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  22. // {40B66661-4972-11d1-A7CA-0000F87571E3}
  23. DEFINE_GUID(CLSID_RSOPScriptSnapInUser,0x40b66661, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  24. //
  25. // RSOP Script node ids
  26. //
  27. // {40B66662-4972-11d1-A7CA-0000F87571E3}
  28. DEFINE_GUID(NODEID_RSOPScriptRootMachine,0x40b66662, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  29. // {40B66663-4972-11d1-A7CA-0000F87571E3}
  30. DEFINE_GUID(NODEID_RSOPScriptRootUser,0x40b66663, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  31. // {40B66664-4972-11d1-A7CA-0000F87571E3}
  32. DEFINE_GUID(NODEID_RSOPScriptRoot,0x40b66664, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  33. // {40B66665-4972-11d1-A7CA-0000F87571E3}
  34. DEFINE_GUID(NODEID_RSOPLogon,0x40b66665, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  35. // {40B66666-4972-11d1-A7CA-0000F87571E3}
  36. DEFINE_GUID(NODEID_RSOPLogoff,0x40b66666, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  37. // {40B66667-4972-11d1-A7CA-0000F87571E3}
  38. DEFINE_GUID(NODEID_RSOPStartup,0x40b66667, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  39. // {40B66668-4972-11d1-A7CA-0000F87571E3}
  40. DEFINE_GUID(NODEID_RSOPShutdown,0x40b66668, 0x4972, 0x11d1, 0xa7, 0xca, 0x0, 0x0, 0xf8, 0x75, 0x71, 0xe3);
  41. //
  42. // RSOP link list data structures
  43. //
  44. typedef struct tagRSOPSCRIPTITEM {
  45. LPTSTR lpCommandLine;
  46. LPTSTR lpArgs;
  47. LPTSTR lpGPOName;
  48. LPTSTR lpDate;
  49. struct tagRSOPSCRIPTITEM * pNext;
  50. } RSOPSCRIPTITEM, *LPRSOPSCRIPTITEM;
  51. typedef struct tagSCRIPTRESULTITEM {
  52. LPRESULTITEM lpResultItem;
  53. LPRSOPSCRIPTITEM lpRSOPScriptItem;
  54. const GUID *pNodeID;
  55. INT iDescStringID;
  56. } SCRIPTRESULTITEM, *LPSCRIPTRESULTITEM;
  57. //
  58. // CScriptsComponentData class
  59. //
  60. class CScriptsComponentData:
  61. public IComponentData,
  62. public IPersistStreamInit,
  63. public ISnapinHelp
  64. {
  65. friend class CScriptsDataObject;
  66. friend class CScriptsSnapIn;
  67. protected:
  68. ULONG m_cRef;
  69. BOOL m_bUserScope;
  70. BOOL m_bRSOP;
  71. HWND m_hwndFrame;
  72. LPCONSOLENAMESPACE m_pScope;
  73. LPCONSOLE2 m_pConsole;
  74. HSCOPEITEM m_hRoot;
  75. LPGPEINFORMATION m_pGPTInformation;
  76. LPRSOPINFORMATION m_pRSOPInformation;
  77. LPTSTR m_pScriptsDir;
  78. LPOLESTR m_pszNamespace;
  79. LPNAMESPACEITEM m_pNameSpaceItems;
  80. DWORD m_dwNameSpaceItemCount;
  81. LPRSOPSCRIPTITEM m_pRSOPLogon;
  82. LPRSOPSCRIPTITEM m_pRSOPLogoff;
  83. LPRSOPSCRIPTITEM m_pRSOPStartup;
  84. LPRSOPSCRIPTITEM m_pRSOPShutdown;
  85. public:
  86. CScriptsComponentData(BOOL bUser, BOOL bRSOP);
  87. ~CScriptsComponentData();
  88. // IUnknown methods
  89. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  90. STDMETHODIMP_(ULONG) AddRef();
  91. STDMETHODIMP_(ULONG) Release();
  92. //
  93. // Implemented IComponentData methods
  94. //
  95. STDMETHODIMP Initialize(LPUNKNOWN pUnknown);
  96. STDMETHODIMP CreateComponent(LPCOMPONENT* ppComponent);
  97. STDMETHODIMP QueryDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  98. STDMETHODIMP Destroy(void);
  99. STDMETHODIMP Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  100. STDMETHODIMP GetDisplayInfo(LPSCOPEDATAITEM pItem);
  101. STDMETHODIMP CompareObjects(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  102. //
  103. // Implemented IPersistStreamInit interface members
  104. //
  105. STDMETHODIMP GetClassID(CLSID *pClassID);
  106. STDMETHODIMP IsDirty(VOID);
  107. STDMETHODIMP Load(IStream *pStm);
  108. STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty);
  109. STDMETHODIMP GetSizeMax(ULARGE_INTEGER *pcbSize);
  110. STDMETHODIMP InitNew(VOID);
  111. //
  112. // Implemented ISnapinHelp interface members
  113. //
  114. STDMETHODIMP GetHelpTopic(LPOLESTR *lpCompiledHelpFile);
  115. private:
  116. HRESULT EnumerateScopePane(LPDATAOBJECT lpDataObject, HSCOPEITEM hParent);
  117. BOOL AddRSOPScriptDataNode(LPTSTR lpCommandLine, LPTSTR lpArgs,
  118. LPTSTR lpGPOName, LPTSTR lpDate, UINT uiScriptType);
  119. VOID FreeRSOPScriptData(VOID);
  120. HRESULT InitializeRSOPScriptsData(VOID);
  121. HRESULT GetGPOFriendlyName(IWbemServices *pIWbemServices,
  122. LPTSTR lpGPOID, BSTR pLanguage,
  123. LPTSTR *pGPOName);
  124. VOID DumpRSOPScriptsData(LPRSOPSCRIPTITEM lpList);
  125. };
  126. //
  127. // ComponentData class factory
  128. //
  129. class CScriptsComponentDataCF : public IClassFactory
  130. {
  131. protected:
  132. ULONG m_cRef;
  133. BOOL m_bUserScope;
  134. BOOL m_bRSOP;
  135. public:
  136. CScriptsComponentDataCF(BOOL bUser, BOOL bRSOP);
  137. ~CScriptsComponentDataCF();
  138. // IUnknown methods
  139. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  140. STDMETHODIMP_(ULONG) AddRef();
  141. STDMETHODIMP_(ULONG) Release();
  142. // IClassFactory methods
  143. STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
  144. STDMETHODIMP LockServer(BOOL);
  145. };
  146. //
  147. // SnapIn class
  148. //
  149. class CScriptsSnapIn:
  150. public IComponent,
  151. public IExtendPropertySheet
  152. {
  153. protected:
  154. ULONG m_cRef;
  155. LPCONSOLE m_pConsole; // Console's IFrame interface
  156. CScriptsComponentData *m_pcd;
  157. LPRESULTDATA m_pResult; // Result pane's interface
  158. LPHEADERCTRL m_pHeader; // Result pane's header control interface
  159. LPCONSOLEVERB m_pConsoleVerb; // pointer the console verb
  160. LPDISPLAYHELP m_pDisplayHelp; // IDisplayHelp interface
  161. WCHAR m_column1[40]; // Text for column 1
  162. INT m_nColumn1Size; // Size of column 1
  163. WCHAR m_column2[40]; // Text for column 2
  164. INT m_nColumn2Size; // Size of column 2
  165. WCHAR m_column3[60]; // Text for column 3
  166. INT m_nColumn3Size; // Size of column 3
  167. WCHAR m_column4[40]; // Text for column 4
  168. INT m_nColumn4Size; // Size of column 4
  169. LONG m_lViewMode; // View mode
  170. static unsigned int m_cfNodeType;
  171. public:
  172. CScriptsSnapIn(CScriptsComponentData *pComponent);
  173. ~CScriptsSnapIn();
  174. //
  175. // IUnknown methods
  176. //
  177. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  178. STDMETHODIMP_(ULONG) AddRef();
  179. STDMETHODIMP_(ULONG) Release();
  180. //
  181. // Implemented IComponent methods
  182. //
  183. STDMETHODIMP Initialize(LPCONSOLE);
  184. STDMETHODIMP Destroy(MMC_COOKIE);
  185. STDMETHODIMP Notify(LPDATAOBJECT, MMC_NOTIFY_TYPE, LPARAM, LPARAM);
  186. STDMETHODIMP QueryDataObject(MMC_COOKIE, DATA_OBJECT_TYPES, LPDATAOBJECT *);
  187. STDMETHODIMP GetDisplayInfo(LPRESULTDATAITEM);
  188. STDMETHODIMP GetResultViewType(MMC_COOKIE, LPOLESTR*, long*);
  189. STDMETHODIMP CompareObjects(LPDATAOBJECT, LPDATAOBJECT);
  190. //
  191. // Implemented IExtendPropertySheet methods
  192. //
  193. STDMETHODIMP CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  194. LONG_PTR handle, LPDATAOBJECT lpDataObject);
  195. STDMETHODIMP QueryPagesFor(LPDATAOBJECT lpDataObject);
  196. private:
  197. static INT_PTR CALLBACK ScriptDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  198. BOOL AddScriptToList (HWND hLV, LPTSTR lpName, LPTSTR lpArgs);
  199. LPTSTR GetSectionNames (LPTSTR lpFileName);
  200. BOOL OnApplyNotify (HWND hDlg);
  201. static INT_PTR CALLBACK ScriptEditDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  202. };
  203. //
  204. // IScriptDataobject interface id
  205. //
  206. // {C14C50E2-FA21-11d0-8CF9-C64377000000}
  207. DEFINE_GUID(IID_IScriptDataObject,0xc14c50e2, 0xfa21, 0x11d0, 0x8c, 0xf9, 0xc6, 0x43, 0x77, 0x0, 0x0, 0x0);
  208. //
  209. // This is a private dataobject interface for GPTs.
  210. // When the GPT snapin receives a dataobject and needs to determine
  211. // if it came from the GPT snapin or a different component, it can QI for
  212. // this interface.
  213. //
  214. #undef INTERFACE
  215. #define INTERFACE IScriptDataObject
  216. DECLARE_INTERFACE_(IScriptDataObject, IUnknown)
  217. {
  218. // *** IUnknown methods ***
  219. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  220. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  221. STDMETHOD_(ULONG,Release) (THIS) PURE;
  222. // *** IScriptDataObject methods ***
  223. STDMETHOD(SetType) (THIS_ DATA_OBJECT_TYPES type) PURE;
  224. STDMETHOD(GetType) (THIS_ DATA_OBJECT_TYPES *type) PURE;
  225. STDMETHOD(SetCookie) (THIS_ MMC_COOKIE cookie) PURE;
  226. STDMETHOD(GetCookie) (THIS_ MMC_COOKIE *cookie) PURE;
  227. };
  228. typedef IScriptDataObject *LPSCRIPTDATAOBJECT;
  229. //
  230. // CScriptsDataObject class
  231. //
  232. class CScriptsDataObject : public IDataObject,
  233. public IScriptDataObject
  234. {
  235. friend class CScriptsSnapIn;
  236. protected:
  237. ULONG m_cRef;
  238. CScriptsComponentData *m_pcd;
  239. DATA_OBJECT_TYPES m_type;
  240. MMC_COOKIE m_cookie;
  241. //
  242. // Clipboard formats that are required by the console
  243. //
  244. static unsigned int m_cfNodeType;
  245. static unsigned int m_cfNodeTypeString;
  246. static unsigned int m_cfDisplayName;
  247. static unsigned int m_cfCoClass;
  248. static unsigned int m_cfDescription;
  249. static unsigned int m_cfHTMLDetails;
  250. public:
  251. CScriptsDataObject(CScriptsComponentData *pComponent);
  252. ~CScriptsDataObject();
  253. //
  254. // IUnknown methods
  255. //
  256. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  257. STDMETHODIMP_(ULONG) AddRef();
  258. STDMETHODIMP_(ULONG) Release();
  259. //
  260. // Implemented IDataObject methods
  261. //
  262. STDMETHOD(GetDataHere)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium);
  263. //
  264. // Unimplemented IDataObject methods
  265. //
  266. STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium)
  267. { return E_NOTIMPL; };
  268. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
  269. { return E_NOTIMPL; };
  270. STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc)
  271. { return E_NOTIMPL; };
  272. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
  273. { return E_NOTIMPL; };
  274. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
  275. { return E_NOTIMPL; };
  276. STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf,
  277. LPADVISESINK pAdvSink, LPDWORD pdwConnection)
  278. { return E_NOTIMPL; };
  279. STDMETHOD(DUnadvise)(DWORD dwConnection)
  280. { return E_NOTIMPL; };
  281. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise)
  282. { return E_NOTIMPL; };
  283. //
  284. // Implemented IScriptDataObject methods
  285. //
  286. STDMETHOD(SetType) (DATA_OBJECT_TYPES type)
  287. { m_type = type; return S_OK; };
  288. STDMETHOD(GetType) (DATA_OBJECT_TYPES *type)
  289. { *type = m_type; return S_OK; };
  290. STDMETHOD(SetCookie) (MMC_COOKIE cookie)
  291. { m_cookie = cookie; return S_OK; };
  292. STDMETHOD(GetCookie) (MMC_COOKIE *cookie)
  293. { *cookie = m_cookie; return S_OK; };
  294. private:
  295. HRESULT CreateNodeTypeData(LPSTGMEDIUM lpMedium);
  296. HRESULT CreateNodeTypeStringData(LPSTGMEDIUM lpMedium);
  297. HRESULT CreateDisplayName(LPSTGMEDIUM lpMedium);
  298. HRESULT CreateCoClassID(LPSTGMEDIUM lpMedium);
  299. HRESULT Create(LPVOID pBuffer, INT len, LPSTGMEDIUM lpMedium);
  300. };