jwagpedit.pas 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  1. {******************************************************************************}
  2. { }
  3. { Group Policy API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: gpedit.h, released June 2000. The original Pascal }
  9. { code is: GPEdit.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaGPEdit.pas,v 1.8 2005/09/06 16:36:50 marquardt Exp $
  43. unit JwaGPEdit;
  44. {$WEAKPACKAGEUNIT}
  45. {$I jediapilib.inc}
  46. interface
  47. uses
  48. JwaActiveX, JwaPrSht, JwaWindows;
  49. {$HPPEMIT ''}
  50. {$HPPEMIT '#include "GPEdit.h"'}
  51. {$HPPEMIT ''}
  52. type
  53. LPOLESTR = POleStr;
  54. {$NODEFINE LPOLESTR}
  55. //-----------------------------------------------------------------------------
  56. //
  57. // GPEDIT.H - Definitions and prototypes for Group Policy
  58. //
  59. // Copyright 1997-1999, Microsoft Corporation
  60. //
  61. //-----------------------------------------------------------------------------
  62. //
  63. // Terminology
  64. //
  65. // Group Policy Editor - The tool to view a Group Policy Object.
  66. //
  67. // Group Policy Object - A collection of administrator defined policies.
  68. // Each Group Policy Object (GPO) has both file system
  69. // and Active Directory storage available to it.
  70. //
  71. // IGPEInformation - The interface MMC Snapin Extensions use to
  72. // talk to the Group Policy Editor.
  73. //
  74. // IGroupPolicyObject - The interface used to create/edit a GPO directly
  75. // without going through the Group Policy Editor
  76. //
  77. //
  78. // Group Policy Editor MMC SnapIn GUID
  79. //
  80. // {8FC0B734-A0E1-11d1-A7D3-0000F87571E3}
  81. const
  82. CLSID_GPESnapIn: TGUID = (
  83. D1:$8fc0b734; D2:$a0e1; D3:$11d1; D4:($a7, $d3, $0, $0, $f8, $75, $71, $e3));
  84. {$EXTERNALSYM CLSID_GPESnapIn}
  85. //
  86. // Group Policy Editor node ids
  87. //
  88. //
  89. // Computer Configuration\Windows Settings
  90. // {8FC0B737-A0E1-11d1-A7D3-0000F87571E3}
  91. //
  92. NODEID_Machine: TGUID = (
  93. D1:$8fc0b737; D2:$a0e1; D3:$11d1; D4:($a7, $d3, $0, $0, $f8, $75, $71, $e3));
  94. {$EXTERNALSYM NODEID_Machine}
  95. //
  96. // Computer Configuration\Software Settings
  97. // {8FC0B73A-A0E1-11d1-A7D3-0000F87571E3}
  98. //
  99. NODEID_MachineSWSettings: TGUID = (
  100. D1:$8fc0b73a; D2:$a0e1; D3:$11d1; D4:($a7, $d3, $0, $0, $f8, $75, $71, $e3));
  101. {$EXTERNALSYM NODEID_MachineSWSettings}
  102. //
  103. // User Configuration\Windows Settings
  104. // {8FC0B738-A0E1-11d1-A7D3-0000F87571E3}
  105. //
  106. NODEID_User: TGUID = (
  107. D1:$8fc0b738; D2:$a0e1; D3:$11d1; D4:($a7, $d3, $0, $0, $f8, $75, $71, $e3));
  108. {$EXTERNALSYM NODEID_User}
  109. //
  110. // User Configuration\Software Settings
  111. // {8FC0B73C-A0E1-11d1-A7D3-0000F87571E3}
  112. //
  113. NODEID_UserSWSettings: TGUID = (
  114. D1:$8fc0b73c; D2:$a0e1; D3:$11d1; D4:($a7, $d3, $0, $0, $f8, $75, $71, $e3));
  115. {$EXTERNALSYM NODEID_UserSWSettings}
  116. //
  117. // IGPEInformation interface id
  118. //
  119. // {8FC0B735-A0E1-11d1-A7D3-0000F87571E3}
  120. IID_IGPEInformation: TGUID = (
  121. D1:$8fc0b735; D2:$a0e1; D3:$11d1; D4:($a7, $d3, $0, $0, $f8, $75, $71, $e3));
  122. {$EXTERNALSYM IID_IGPEInformation}
  123. //
  124. // Group Policy Object class id
  125. //
  126. // {EA502722-A23D-11d1-A7D3-0000F87571E3}
  127. CLSID_GroupPolicyObject: TGUID = (
  128. D1:$ea502722; D2:$a23d; D3:$11d1; D4:($a7, $d3, $0, $0, $f8, $75, $71, $e3));
  129. {$EXTERNALSYM CLSID_GroupPolicyObject}
  130. //
  131. // Group Policy Object interface id
  132. //
  133. // {EA502723-A23D-11d1-A7D3-0000F87571E3}
  134. IID_IGroupPolicyObject: TGUID = (
  135. D1:$ea502723; D2:$a23d; D3:$11d1; D4:($a7, $d3, $0, $0, $f8, $75, $71, $e3));
  136. {$EXTERNALSYM IID_IGroupPolicyObject}
  137. //
  138. // GUID that identifies the registry extension
  139. //
  140. REGISTRY_EXTENSION_GUID: TGUID = (
  141. D1:$35378EAC; D2:$683F; D3:$11D2; D4:($A8, $9A, $00, $C0, $4F, $BB, $CF, $A2));
  142. {$EXTERNALSYM IID_IGroupPolicyObject}
  143. //========================================================================================
  144. //
  145. // Resultant Set of Policy node ids
  146. //
  147. //========================================================================================
  148. //
  149. // Resultant Set of Policy MMC SnapIn GUID
  150. //
  151. // {6DC3804B-7212-458D-ADB0-9A07E2AE1FA2}
  152. CLSID_RSOPSnapIn: TGUID = (
  153. D1:$6dc3804b; D2:$7212; D3:$458d; D4:($ad, $b0, $9a, $07, $e2, $ae, $1f, $a2));
  154. {$EXTERNALSYM CLSID_RSOPSnapIn}
  155. //
  156. // Computer Configuration\Windows Settings
  157. // {BD4C1A2E-0B7A-4A62-A6B0-C0577539C97E}
  158. //
  159. NODEID_RSOPMachine: TGUID = (
  160. D1:$bd4c1a2e; D2:$0b7a; D3:$4a62; D4:($a6, $b0, $c0, $57, $75, $39, $c9, $7e));
  161. {$EXTERNALSYM NODEID_RSOPMachine}
  162. //
  163. // Computer Configuration\Software Settings
  164. // {6A76273E-EB8E-45DB-94C5-25663A5f2C1A}
  165. //
  166. NODEID_RSOPMachineSWSettings: TGUID = (
  167. D1:$6a76273e; D2:$eb8e; D3:$45db; D4:($94, $c5, $25, $66, $3a, $5f, $2c, $1a));
  168. {$EXTERNALSYM NODEID_RSOPMachineSWSettings}
  169. //
  170. // User Configuration\Windows Settings
  171. // {AB87364F-0CEC-4CD8-9BF8-898F34628FB8}
  172. //
  173. NODEID_RSOPUser: TGUID = (
  174. D1:$ab87364f; D2:$0cec; D3:$4cd8; D4:($9b, $f8, $89, $8f, $34, $62, $8f, $b8));
  175. {$EXTERNALSYM NODEID_RSOPUser}
  176. //
  177. // User Configuration\Software Settings
  178. // {E52C5CE3-FD27-4402-84DE-D9A5F2858910}
  179. //
  180. NODEID_RSOPUserSWSettings: TGUID = (
  181. D1:$e52c5ce3; D2:$fd27; D3:$4402; D4:($84, $de, $d9, $a5, $f2, $85, $89, $10));
  182. {$EXTERNALSYM NODEID_RSOPUserSWSettings}
  183. //
  184. // IRSOPInformation interface id
  185. //
  186. // {9A5A81B5-D9C7-49EF-9D11-DDF50968C48D}
  187. IID_IRSOPInformation: TGUID = (
  188. D1:$9a5a81b5; D2:$d9c7; D3:$49ef; D4:($9d, $11, $dd, $f5, $09, $68, $c4, $8d));
  189. {$EXTERNALSYM IID_IRSOPInformation}
  190. // #include <objbase.h>
  191. //
  192. // Group Policy Object Section flags
  193. //
  194. const
  195. GPO_SECTION_ROOT = 0; // Root
  196. {$EXTERNALSYM GPO_SECTION_ROOT}
  197. GPO_SECTION_USER = 1; // User
  198. {$EXTERNALSYM GPO_SECTION_USER}
  199. GPO_SECTION_MACHINE = 2; // Machine
  200. {$EXTERNALSYM GPO_SECTION_MACHINE}
  201. //
  202. // Group Policy Object types
  203. //
  204. type
  205. _GROUP_POLICY_OBJECT_TYPE = (
  206. GPOTypeLocal, // GPO on the local machine
  207. GPOTypeRemote, // GPO on a remote machine
  208. GPOTypeDS); // GPO in the Active Directory
  209. {$EXTERNALSYM _GROUP_POLICY_OBJECT_TYPE}
  210. GROUP_POLICY_OBJECT_TYPE = _GROUP_POLICY_OBJECT_TYPE;
  211. {$EXTERNALSYM GROUP_POLICY_OBJECT_TYPE}
  212. PGROUP_POLICY_OBJECT_TYPE = ^GROUP_POLICY_OBJECT_TYPE;
  213. {$EXTERNALSYM PGROUP_POLICY_OBJECT_TYPE}
  214. TGroupPolicyObjectType = GROUP_POLICY_OBJECT_TYPE;
  215. PGroupPolicyObjectType = PGROUP_POLICY_OBJECT_TYPE;
  216. //
  217. // Group Policy Hint types
  218. //
  219. _GROUP_POLICY_HINT_TYPE = (
  220. GPHintUnknown, // No link information available
  221. GPHintMachine, // GPO linked to a machine (local or remote)
  222. GPHintSite, // GPO linked to a site
  223. GPHintDomain, // GPO linked to a domain
  224. GPHintOrganizationalUnit); // GPO linked to a organizational unit
  225. {$EXTERNALSYM _GROUP_POLICY_HINT_TYPE}
  226. GROUP_POLICY_HINT_TYPE = _GROUP_POLICY_HINT_TYPE;
  227. {$EXTERNALSYM GROUP_POLICY_HINT_TYPE}
  228. PGROUP_POLICY_HINT_TYPE = ^GROUP_POLICY_HINT_TYPE;
  229. {$EXTERNALSYM PGROUP_POLICY_HINT_TYPE}
  230. TGroupPolicyHintType = GROUP_POLICY_HINT_TYPE;
  231. PGroupPolicyHintType = PGROUP_POLICY_HINT_TYPE;
  232. IGPEInformation = interface (IUnknown)
  233. ['{8FC0B735-A0E1-11d1-A7D3-0000F87571E3}']
  234. // *** IGPEInformation methods ***
  235. //
  236. // Returns the unique Group Policy Object name (a GUID)
  237. //
  238. // pszName contains the name on return
  239. // cchMaxLength is the max number of characters that can be stored in pszName
  240. //
  241. function GetName(pszName: LPOLESTR; cchMaxLength: Integer): HRESULT; stdcall;
  242. //
  243. // Returns the friendly display name for this Group Policy Object
  244. //
  245. // pszName contains the name on return
  246. // cchMaxLength is the max number of characters that can be stored in pszName
  247. //
  248. function GetDisplayName(pszName: LPOLESTR; cchMaxLength: Integer): HRESULT; stdcall;
  249. //
  250. // Returns a registry key handle for the requested section. The returned
  251. // key is the root of the registry, not the Policies subkey. To set / read
  252. // a value in the Policies subkey, you will need to call RegOpenKeyEx to
  253. // open Software\Policies subkey first.
  254. //
  255. // The handle has been opened with ALL ACCESS rights. Call RegCloseKey
  256. // on the handle when finished.
  257. //
  258. // dwSection is either GPO_SECTION_USER or GPO_SECTION_MACHINE
  259. // hKey contains the registry key on return
  260. //
  261. function GetRegistryKey(dwSection: DWORD; var hKey: HKEY): HRESULT; stdcall;
  262. //
  263. // Returns the Active Directory path to the root of the request section.
  264. // The path is in ADSI name format.
  265. //
  266. // dwSection is one of the GPO_SECTION_* flags
  267. // pszPath contains the path on return
  268. // cchMaxPath is the max number of characters that can be stored in pszPath
  269. //
  270. function GetDSPath(dwSection: DWORD; pszPath: LPOLESTR; cchMaxPath: Integer): HRESULT; stdcall;
  271. //
  272. // Returns the UNC path to the root of the requested section.
  273. //
  274. // dwSection is one of the GPO_SECTION_* flags
  275. // pszPath contains the path on return
  276. // cchMaxPath is the number of characters that can be stored in pszPath.
  277. //
  278. function GetFileSysPath(dwSection: DWORD; pszPath: LPOLESTR; cchMaxPath: Integer): HRESULT; stdcall;
  279. //
  280. // Returns the user preferences (options)
  281. //
  282. // Currently, there are no options defined. This is reserved for future use.
  283. //
  284. // dwOptions receives a bitmask value
  285. //
  286. function GetOptions(var dwOptions: DWORD): HRESULT; stdcall;
  287. //
  288. // Returns the type of GPO being edited.
  289. //
  290. // The three types are: a GPO in the Active Directory, the GPO on the local machine,
  291. // and the GPO on a remote machine.
  292. //
  293. // Machine GPOs only have file system storage (no Active Directory storage available).
  294. // If GetDSPath is called for a machine GPO, the function will succeed
  295. // and the returned buffer will be the empty string ""
  296. //
  297. // Active Directory GPOs have both file system and Active Directory storage available to them.
  298. //
  299. // gpoType receives one of the type flags listed above.
  300. //
  301. function GetType(var gpoType: GROUP_POLICY_OBJECT_TYPE): HRESULT; stdcall;
  302. //
  303. // Returns the type of Active Directory object (or machine) that could be linked to
  304. // this GPO
  305. //
  306. // This is a hint api only. The GPE does not know which Active Directory objects are
  307. // linked to a particular GPO, but it can offer a hint based upon how the
  308. // user started the GPE.
  309. //
  310. // Use this method with great caution. Some extensions might want to
  311. // customize their user interface based upon the scoping for this GPO,
  312. // but it is easy to offer the wrong namespace. Best advice is to
  313. // always offer your full user interface, but if you choose to use this
  314. // method, always offer your full user interface if you recieve the
  315. // unknown hint back.
  316. //
  317. // gpHint receives one of the hint flags listed above.
  318. //
  319. function GetHint(var gpHint: GROUP_POLICY_HINT_TYPE): HRESULT; stdcall;
  320. //
  321. // Informs the Group Policy Editor that policy settings have changed.
  322. // Extensions MUST call this methold every time a change is made
  323. // to a Group Policy Object.
  324. //
  325. // bMachine specifies if machine or user policy has changed.
  326. // bAdd specifies whether this is an add or delete.
  327. // pGuidExtension is the guid or unique name of extension that
  328. // will process this GPO.
  329. // pGuidSnapin is the guid or unique name of snapin that is making
  330. // this call
  331. //
  332. function PolicyChanged(bMachine, bAdd: BOOL; const pGuidExtension, pGuidSnapin: GUID): HRESULT; stdcall;
  333. end;
  334. {$EXTERNALSYM IGPEInformation}
  335. LPGPEINFORMATION = ^IGPEInformation;
  336. {$EXTERNALSYM LPGPEINFORMATION}
  337. //
  338. // Group Policy Object open / creation flags
  339. //
  340. const
  341. GPO_OPEN_LOAD_REGISTRY = $00000001; // Load the registry files
  342. {$EXTERNALSYM GPO_OPEN_LOAD_REGISTRY}
  343. GPO_OPEN_READ_ONLY = $00000002; // Open the GPO as read only
  344. {$EXTERNALSYM GPO_OPEN_READ_ONLY}
  345. //
  346. // Group Policy Object option flags
  347. //
  348. const
  349. GPO_OPTION_DISABLE_USER = $00000001; // The user portion of this GPO is disabled
  350. {$EXTERNALSYM GPO_OPTION_DISABLE_USER}
  351. GPO_OPTION_DISABLE_MACHINE = $00000002; // The machine portion of this GPO is disabled
  352. {$EXTERNALSYM GPO_OPTION_DISABLE_MACHINE}
  353. type
  354. IGroupPolicyObject = interface (IUnknown)
  355. ['{EA502723-A23D-11d1-A7D3-0000F87571E3}']
  356. // *** IGroupPolicyObject methods ***
  357. //
  358. // Creates a new GPO in the Active Directory with the given friendly name
  359. // and opens it via OpenDSGPO(). If pszDomainName contains a domain
  360. // controller name, the GPO will be created on that DC. If it does not
  361. // specify a domain controller name, the method will select a DC on
  362. // the callers behalf.
  363. //
  364. // pszDomainName contains the ADSI path of the domain root
  365. // pszDisplayName contains the friendly display name
  366. // dwFlags is a bitmask of GPO open / creation flags listed above
  367. //
  368. function New(pszDomainName, pszDisplayName: LPOLESTR; dwFlags: DWORD): HRESULT; stdcall;
  369. //
  370. // Opens the specified Group Policy Object in the Active Directory
  371. // based upon the passed in flags. If pszPath contains a domain
  372. // controller name, the GPO will be opened on that DC. If it does
  373. // not contain a domain controller name, the method will select a
  374. // DC on the callers behalf. If the registry is not loaded,
  375. // GetRegistryKey() will return E_FAIL.
  376. //
  377. // pszPath contains the ADSI path to the GPO to open
  378. // dwFlags is a bitmask of GPO open / creation flags listed above
  379. //
  380. function OpenDSGPO(pszPath: LPOLESTR; dwFlags: DWORD): HRESULT; stdcall;
  381. //
  382. // Opens the default Group Policy Object on this machine with the
  383. // dwFlags options listed above. If the registry is not loaded,
  384. // GetRegistryKey() will return E_FAIL.
  385. //
  386. // dwFlags is a bitmask of GPO open / creation flags listed above
  387. //
  388. function OpenLocalMachineGPO(dwFlags: DWORD): HRESULT; stdcall;
  389. //
  390. // Opens the default Group Policy Object on a remote machine with the
  391. // dwFlags options listed above. If the registry is not loaded,
  392. // GetRegistryKey() will return E_FAIL.
  393. //
  394. // pszComputerName contains the machine name in \\machine format
  395. // dwFlags is a bitmask of GPO open / creation flags listed above
  396. //
  397. function OpenRemoteMachineGPO(pszComputerName: LPOLESTR; dwFlags: DWORD): HRESULT; stdcall;
  398. //
  399. // Flushes the registry settings to disk and updates the revision
  400. // number of the GPO.
  401. //
  402. // bMachine specifies if machine or user should be saved.
  403. // bAdd specifies whether this is an add or delete.
  404. // pGuidExtension is the guid or unique name of extension that
  405. // will process this GPO.
  406. // pGuid is a guid
  407. //
  408. function Save(bMachine, bAdd: BOOL; const pGuidExtension, pGuid: GUID): HRESULT; stdcall;
  409. //
  410. // Deletes this Group Policy Object.
  411. //
  412. // After calling this method, no other methods are valid to call
  413. // since the data will have been deleted.
  414. //
  415. function Delete: HRESULT; stdcall;
  416. //
  417. // Returns the unique Group Policy Object name
  418. //
  419. // For Active Directory policy objects, this is a GUID
  420. // For the local policy object, it is the string "Local"
  421. // For remote policy objects, it is the computername
  422. //
  423. // pszName contains the name on return
  424. // cchMaxLength is the max number of characters that can be stored in pszName
  425. //
  426. function GetName(pszName: LPOLESTR; cchMaxLength: Integer): HRESULT; stdcall;
  427. //
  428. // Returns the friendly display name for this Group Policy Object
  429. //
  430. // pszName contains the name on return
  431. // cchMaxLength is the max number of characters that can be stored in pszName
  432. //
  433. function GetDisplayName(pszName: LPOLESTR; cchMaxLength: Integer): HRESULT; stdcall;
  434. //
  435. // Sets the friendly display name for this Group Policy Object
  436. //
  437. // pszName is the new display name
  438. //
  439. function SetDisplayName(pszName: LPOLESTR): HRESULT; stdcall;
  440. //
  441. // Returns the path to the Group Policy Object
  442. //
  443. //
  444. // If the GPO is an Active Directory object, the path is in ADSI name format.
  445. // If the GPO is a machine object, it is a file system path
  446. //
  447. // pszPath contains the path on return
  448. // cchMaxPath is the max number of characters that can be stored in pszPath
  449. //
  450. function GetPath(pszPath: LPOLESTR; cchMaxPath: Integer): HRESULT; stdcall;
  451. //
  452. // Returns the Active Directory path to the root of the request section.
  453. // The path is in DN name format.
  454. //
  455. // dwSection is one of the GPO_SECTION_* flags
  456. // pszPath contains the path on return
  457. // cchMaxPath is the max number of characters that can be stored in pszPath
  458. //
  459. function GetDSPath(dwSection: DWORD; pszPath: LPOLESTR; cchMaxPath: Integer): HRESULT; stdcall;
  460. //
  461. // Returns the UNC path to the root of the requested section.
  462. //
  463. // dwSection is one of the GPO_SECTION_* flags
  464. // pszPath contains the path on return
  465. // cchMaxPath is the number of characters that can be stored in pszPath.
  466. //
  467. function GetFileSysPath(dwSection: DWORD; pszPath: LPOLESTR; cchMaxPath: Integer): HRESULT; stdcall;
  468. //
  469. // Returns a registry key handle for the requested section. The returned
  470. // key is the root of the registry, not the Policies subkey. To set / read
  471. // a value in the Policies subkey, you will need to call RegOpenKeyEx to
  472. // open Software\Policies subkey first.
  473. //
  474. // The handle has been opened with ALL ACCESS rights. Call RegCloseKey
  475. // on the handle when finished.
  476. //
  477. // If the GPO was loaded / created without the registry being loaded
  478. // this method will return E_FAIL.
  479. //
  480. // dwSection is either GPO_SECTION_USER or GPO_SECTION_MACHINE
  481. // hKey contains the registry key on return
  482. //
  483. function GetRegistryKey(dwSection: DWORD; var hKey: HKEY): HRESULT; stdcall;
  484. //
  485. // Returns any options for this Group Policy Object
  486. //
  487. // dwOptions receives the GPO_OPTION_* flags
  488. //
  489. function GetOptions(var dwOptions: DWORD): HRESULT; stdcall;
  490. //
  491. // Sets any options for this Group Policy Object
  492. //
  493. // This method sets any options for this GPO. To change
  494. // an option, that flag must be set in the mask field.
  495. // If the flag is in the mask field, then the dwOptions
  496. // field is read for the current state.
  497. //
  498. // For example: to disable the GPO, make this call
  499. //
  500. // SetOptions (GPO_OPTION_DISABLED, GPO_OPTION_DISABLED);
  501. //
  502. // dwOptions specifies one or more GPO_OPTION_* flags
  503. // dwMask specificies which of the dwOptions to change
  504. //
  505. function SetOptions(dwOptions, dwMask: DWORD): HRESULT; stdcall;
  506. //
  507. // Returns the type of GPO being edited.
  508. //
  509. // The three types are: a GPO in the Active Directory, the GPO on the local machine,
  510. // and the GPO on a remote machine.
  511. //
  512. // Machine GPOs only have file system storage (no Active Directory storage available).
  513. // If GetDSPath is called for a machine GPO, the function will succeed
  514. // and the returned buffer will be the empty string ""
  515. //
  516. // Active Directory GPOs have both file system and Active Directory storage available to them.
  517. //
  518. // gpoType receives one of the type flags
  519. //
  520. function GetType(var gpoType: GROUP_POLICY_OBJECT_TYPE): HRESULT; stdcall;
  521. //
  522. // Returns the machine name of the remote GPO
  523. //
  524. // This method returns the name passed to OpenRemoteMachineGPO.
  525. //
  526. // pszName contains the name on return
  527. // cchMaxLength is the max number of characters that can be stored in pszName
  528. //
  529. function GetMachineName(pszName: LPOLESTR; cchMaxLength: Integer): HRESULT; stdcall;
  530. //
  531. // Returns an array of property sheet pages and the number of pages
  532. // in the array
  533. //
  534. // Note, this method will allocate memory for the array with
  535. // LocalAlloc. When finished, the caller should free the array
  536. // with LocalFree
  537. //
  538. // hPages address of the pointer for the array of property sheet pages
  539. // uPageCount receives the number of pages in the array
  540. //
  541. function GetPropertySheetPages(var hPages: PHPROPSHEETPAGE; var uPageCount: UINT): HRESULT; stdcall;
  542. end;
  543. {$EXTERNALSYM IGroupPolicyObject}
  544. LPGROUPPOLICYOBJECT = ^IGroupPolicyObject;
  545. {$EXTERNALSYM LPGROUPPOLICYOBJECT}
  546. //
  547. // RSOP flags
  548. //
  549. const
  550. RSOP_INFO_FLAG_DIAGNOSTIC_MODE = $00000001; // Running in diagnostic mode vs planning mode
  551. {$EXTERNALSYM RSOP_INFO_FLAG_DIAGNOSTIC_MODE}
  552. type
  553. IRSOPInformation = interface (IUnknown)
  554. ['{9A5A81B5-D9C7-49EF-9D11-DDF50968C48D}']
  555. // *** IRSOPInformation methods ***
  556. //
  557. // Returns the namespace for the RSOP data
  558. //
  559. // dwSection is either GPO_SECTION_USER or GPO_SECTION_MACHINE
  560. // pszName contains the namespace on return
  561. // cchMaxLength is the max number of characters that can be stored in pszName
  562. //
  563. function GetNamespace(dwSection: DWORD; pszName: LPOLESTR; cchMaxLength: Integer): HRESULT; stdcall;
  564. //
  565. // Returns information about the RSOP session
  566. //
  567. // pdwFlags points to a DWORD which contains the flags on return
  568. //
  569. function GetFlags(var pdwFlags: DWORD): HRESULT; stdcall;
  570. //
  571. // Returns the event log text for a specific entry
  572. //
  573. // lpEventSource - event log source name
  574. // lpEventLogName - event log name
  575. // lpEventTime - event log time in WMI datetime format
  576. // dwEventID - event ID
  577. // lpText - Receives a pointer to a buffer containing the text.
  578. // The caller should free this buffer with CoTaskMemFree.
  579. //
  580. function GetEventLogEntryText(pszEventSource, pszEventLogName, pszEventTime: LPOLESTR;
  581. dwEventID: DWORD; out ppszText: LPOLESTR): HRESULT; stdcall;
  582. end;
  583. {$EXTERNALSYM IRSOPInformation}
  584. LPRSOPINFORMATION = IRSOPInformation;
  585. {$EXTERNALSYM LPRSOPINFORMATION}
  586. //=============================================================================
  587. //
  588. // CreateGPOLink
  589. //
  590. // Creates a link to a GPO for the specified Site, Domain, or Organizational Unit
  591. //
  592. // lpGPO - ADSI path to the GPO
  593. // lpContainer - ADSI path to the Site, Domain, or Organizational Unit
  594. // fHighPriority - Create the link as the highest or lowest priority
  595. //
  596. // Returns: S_OK if successful
  597. //
  598. //=============================================================================
  599. function CreateGPOLink(lpGPO, lpContainer: LPOLESTR; fHighPriority: BOOL): HRESULT; stdcall;
  600. {$EXTERNALSYM CreateGPOLink}
  601. //=============================================================================
  602. //
  603. // DeleteGPOLink
  604. //
  605. // Deletes a link to a GPO for the specified Site, Domain, or Organizational Unit
  606. //
  607. // lpGPO - ADSI path to the GPO
  608. // lpContainer - ADSI path to the Site, Domain, or Organizational Unit
  609. //
  610. // Returns: S_OK if successful
  611. //
  612. //=============================================================================
  613. function DeleteGPOLink(lpGPO, lpContainer: LPOLESTR): HRESULT; stdcall;
  614. {$EXTERNALSYM DeleteGPOLink}
  615. //=============================================================================
  616. //
  617. // DeleteAllGPOLinks
  618. //
  619. // Deletes all GPO links for the specified Site, Domain, or Organizational Unit
  620. //
  621. // lpContainer - ADSI path to the Site, Domain, or Organizational Unit
  622. //
  623. // Returns: S_OK if successful
  624. //
  625. //=============================================================================
  626. function DeleteAllGPOLinks(lpContainer: LPOLESTR): HRESULT; stdcall;
  627. {$EXTERNALSYM DeleteAllGPOLinks}
  628. //=============================================================================
  629. //
  630. // BrowseForGPO
  631. //
  632. // Displays the GPO browser dialog
  633. //
  634. // lpBrowseInfo - Address of a GPOBROWSEINFO structure
  635. //
  636. // Returns: S_OK if successful
  637. //
  638. //=============================================================================
  639. //
  640. // Flags passed in the dwFlags field of the GPOBROWSEINFO structure
  641. //
  642. const
  643. GPO_BROWSE_DISABLENEW = $00000001; // Disables the New GPO functionality on all pages except "All"
  644. {$EXTERNALSYM GPO_BROWSE_DISABLENEW}
  645. GPO_BROWSE_NOCOMPUTERS = $00000002; // Removes the Computers tab
  646. {$EXTERNALSYM GPO_BROWSE_NOCOMPUTERS}
  647. GPO_BROWSE_NODSGPOS = $00000004; // Removes the Domain/OU and Sites tabs
  648. {$EXTERNALSYM GPO_BROWSE_NODSGPOS}
  649. GPO_BROWSE_OPENBUTTON = $00000008; // Change the Ok button to say Open
  650. {$EXTERNALSYM GPO_BROWSE_OPENBUTTON}
  651. GPO_BROWSE_INITTOALL = $00000010; // Initialize the dialog focused on the All pane
  652. {$EXTERNALSYM GPO_BROWSE_INITTOALL}
  653. type
  654. tag_GPOBROWSEINFO = record
  655. dwSize: DWORD; // [in] Initialized to the size of this structure
  656. dwFlags: DWORD; // [in] Flags defined above
  657. hwndOwner: HWND; // [in] Parent window handle (can be NULL)
  658. lpTitle: LPOLESTR; // [in] Title bar text. If NULL, "Browse for a Group Policy Object" will be the default text
  659. lpInitialOU: LPOLESTR; // [in] Initial Domain/Organizational Unit to open focus on
  660. lpDSPath: LPOLESTR; // [in/out] Pointer to the buffer that receives the Active Directory GPO path
  661. dwDSPathSize: DWORD; // [in] Size in characters of buffer given in lpDSPath
  662. lpName: LPOLESTR; // [in/out] Pointer to a buffer that receives either the computer name or
  663. // the friendly name of the GPO (can be NULL)
  664. dwNameSize: DWORD; // [in] Size in characters of buffer given in lpName
  665. gpoType: GROUP_POLICY_OBJECT_TYPE; // [out] Specifies the type of GPO
  666. gpoHint: GROUP_POLICY_HINT_TYPE; // [out] Specifies a hint of the GPO association
  667. end;
  668. {$EXTERNALSYM tag_GPOBROWSEINFO}
  669. GPOBROWSEINFO = tag_GPOBROWSEINFO;
  670. {$EXTERNALSYM GPOBROWSEINFO}
  671. LPGPOBROWSEINFO = ^GPOBROWSEINFO;
  672. TGpoBrowseInfo = GPOBROWSEINFO;
  673. PGpoBrowseInfo = LPGPOBROWSEINFO;
  674. function BrowseForGPO(var lpBrowseInfo: GPOBROWSEINFO): HRESULT; stdcall;
  675. {$EXTERNALSYM BrowseForGPO}
  676. //=============================================================================
  677. //
  678. // ImportRSoPData
  679. //
  680. // Imports a data file generated by ExportRSoPData
  681. //
  682. // lpNameSpace - Namespace to place the data in
  683. // lpFileName - Filename containing the data
  684. //
  685. // Returns: S_OK if successful
  686. //
  687. // Notes: The namespace specified in lpNameSpace must exist prior to calling
  688. // this function.
  689. //
  690. //=============================================================================
  691. function ImportRSoPData(lpNameSpace, lpFileName: LPOLESTR): HRESULT; stdcall;
  692. {$EXTERNALSYM ImportRSoPData}
  693. //=============================================================================
  694. //
  695. // ExportRSoPData
  696. //
  697. // Exports a WBEM namespace containing RSoP information to a data file.
  698. // This data file can be imported to a WBEM namespace using ImportRSoPData.
  699. //
  700. // lpNameSpace - Namespace to read the data from
  701. // lpFileName - Filename to receive the data
  702. //
  703. // Returns: S_OK if successful
  704. //
  705. // Notes: This function should be called twice. Once for the user data
  706. // and once for the computer data.
  707. //
  708. //=============================================================================
  709. function ExportRSoPData(lpNameSpace, lpFileName: LPOLESTR): HRESULT; stdcall;
  710. {$EXTERNALSYM ExportRSoPData}
  711. implementation
  712. uses
  713. JwaWinDLLNames;
  714. {$IFDEF DYNAMIC_LINK}
  715. var
  716. _CreateGPOLink: Pointer;
  717. function CreateGPOLink;
  718. begin
  719. GetProcedureAddress(_CreateGPOLink, gpeditlib, 'CreateGPOLink');
  720. asm
  721. MOV ESP, EBP
  722. POP EBP
  723. JMP [_CreateGPOLink]
  724. end;
  725. end;
  726. var
  727. _DeleteGPOLink: Pointer;
  728. function DeleteGPOLink;
  729. begin
  730. GetProcedureAddress(_DeleteGPOLink, gpeditlib, 'DeleteGPOLink');
  731. asm
  732. MOV ESP, EBP
  733. POP EBP
  734. JMP [_DeleteGPOLink]
  735. end;
  736. end;
  737. var
  738. _DeleteAllGPOLinks: Pointer;
  739. function DeleteAllGPOLinks;
  740. begin
  741. GetProcedureAddress(_DeleteAllGPOLinks, gpeditlib, 'DeleteAllGPOLinks');
  742. asm
  743. MOV ESP, EBP
  744. POP EBP
  745. JMP [_DeleteAllGPOLinks]
  746. end;
  747. end;
  748. var
  749. _BrowseForGPO: Pointer;
  750. function BrowseForGPO;
  751. begin
  752. GetProcedureAddress(_BrowseForGPO, gpeditlib, 'BrowseForGPO');
  753. asm
  754. MOV ESP, EBP
  755. POP EBP
  756. JMP [_BrowseForGPO]
  757. end;
  758. end;
  759. var
  760. _ImportRSoPData: Pointer;
  761. function ImportRSoPData;
  762. begin
  763. GetProcedureAddress(_ImportRSoPData, gpeditlib, 'ImportRSoPData');
  764. asm
  765. MOV ESP, EBP
  766. POP EBP
  767. JMP [_ImportRSoPData]
  768. end;
  769. end;
  770. var
  771. _ExportRSoPData: Pointer;
  772. function ExportRSoPData;
  773. begin
  774. GetProcedureAddress(_ExportRSoPData, gpeditlib, 'ExportRSoPData');
  775. asm
  776. MOV ESP, EBP
  777. POP EBP
  778. JMP [_ExportRSoPData]
  779. end;
  780. end;
  781. {$ELSE}
  782. function CreateGPOLink; external gpeditlib name 'CreateGPOLink';
  783. function DeleteGPOLink; external gpeditlib name 'DeleteGPOLink';
  784. function DeleteAllGPOLinks; external gpeditlib name 'DeleteAllGPOLinks';
  785. function BrowseForGPO; external gpeditlib name 'BrowseForGPO';
  786. function ImportRSoPData; external gpeditlib name 'ImportRSoPData';
  787. function ExportRSoPData; external gpeditlib name 'ExportRSoPData';
  788. {$ENDIF DYNAMIC_LINK}
  789. end.