jwadsclient.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. {******************************************************************************}
  2. { }
  3. { Active Directory Display 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: dsclient.h, released June 2000. The original Pascal }
  9. { code is: DsClient.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. unit JwaDSClient;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "dsclient.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaAdsTLB, JwaWinType;
  51. //---------------------------------------------------------------------------//
  52. // CLSIDs exposed for the dsclient.
  53. //---------------------------------------------------------------------------//
  54. // this CLSID is used to signal that the DSOBJECTNAMEs structure originated
  55. // for the Microsoft DS.
  56. const
  57. CLSID_MicrosoftDS: TGUID = (
  58. D1:$fe1290f0; D2:$cfbd; D3:$11cf; D4:($a3, $30, $0, $aa, $0, $c1, $6e, $65));
  59. {$EXTERNALSYM CLSID_MicrosoftDS}
  60. //CLSID_DsFolder: = CLSID_MicrosoftDS;
  61. CLSID_DsFolder: TGUID = (
  62. D1:$fe1290f0; D2:$cfbd; D3:$11cf; D4:($a3, $30, $0, $aa, $0, $c1, $6e, $65));
  63. {$EXTERNALSYM CLSID_DsFolder}
  64. // this is the CLSID used by clients to get the IShellExtInit, IPropSheetExt
  65. // and IContextMenus exposed from dsuiext.dll.
  66. CLSID_DsPropertyPages: TGUID = (
  67. D1:$d45d530; D2:$764b; D3:$11d0; D4:($a1, $ca, $0, $aa, $0, $c1, $6e, $65));
  68. {$EXTERNALSYM CLSID_DsPropertyPages}
  69. CLSID_DsDomainTreeBrowser: TGUID = (
  70. D1:$1698790a; D2:$e2b4; D3:$11d0; D4:($b0, $b1, $00, $c0, $4f, $d8, $dc, $a6));
  71. {$EXTERNALSYM CLSID_DsDomainTreeBrowser}
  72. IID_IDsBrowseDomainTree: TGUID = (
  73. D1:$7cabcf1e; D2:$78f5; D3:$11d2; D4:($96, $c, $0, $c0, $4f, $a3, $1a, $86));
  74. {$EXTERNALSYM IID_IDsBrowseDomainTree}
  75. CLSID_DsDisplaySpecifier: TGUID = (
  76. D1:$1ab4a8c0; D2:$6a0b; D3:$11d2; D4:($ad, $49, $0, $c0, $4f, $a3, $1a, $86));
  77. {$EXTERNALSYM CLSID_DsDisplaySpecifier}
  78. //IID_IDsDisplaySpecifier = CLSID_DsDisplaySpecifier;
  79. IID_IDsDisplaySpecifier: TGUID = (
  80. D1:$1ab4a8c0; D2:$6a0b; D3:$11d2; D4:($ad, $49, $0, $c0, $4f, $a3, $1a, $86));
  81. {$EXTERNALSYM IID_IDsDisplaySpecifier}
  82. CLSID_DsFolderProperties: TGUID = (
  83. D1:$9e51e0d0; D2:$6e0f; D3:$11d2; D4:($96, $1, $0, $c0, $4f, $a3, $1a, $86));
  84. {$EXTERNALSYM CLSID_DsFolderProperties}
  85. //IID_IDsFolderProperties = CLSID_DsFolderProperties;
  86. IID_IDsFolderProperties: TGUID = (
  87. D1:$9e51e0d0; D2:$6e0f; D3:$11d2; D4:($96, $1, $0, $c0, $4f, $a3, $1a, $86));
  88. {$EXTERNALSYM IID_IDsFolderProperties}
  89. // #include "activeds.h"
  90. //---------------------------------------------------------------------------//
  91. // Clipboard formats used within DSUI
  92. //---------------------------------------------------------------------------//
  93. //
  94. // CF_DSOBJECTS
  95. // ------------
  96. // This clipboard format defines the seleciton for an DS IShellFolder to the
  97. // shell extensions. All strings are stored as BSTR's, and an offset == 0
  98. // is used to indicate that the string is not present.
  99. //
  100. const
  101. DSOBJECT_ISCONTAINER = $00000001; // = 1 => object is a container
  102. {$EXTERNALSYM DSOBJECT_ISCONTAINER}
  103. DSOBJECT_READONLYPAGES = DWORD($80000000); // = 1 => read only pages
  104. {$EXTERNALSYM DSOBJECT_READONLYPAGES}
  105. DSPROVIDER_UNUSED_0 = $00000001;
  106. {$EXTERNALSYM DSPROVIDER_UNUSED_0}
  107. DSPROVIDER_UNUSED_1 = $00000002;
  108. {$EXTERNALSYM DSPROVIDER_UNUSED_1}
  109. DSPROVIDER_UNUSED_2 = $00000004;
  110. {$EXTERNALSYM DSPROVIDER_UNUSED_2}
  111. DSPROVIDER_UNUSED_3 = $00000008;
  112. {$EXTERNALSYM DSPROVIDER_UNUSED_3}
  113. DSPROVIDER_ADVANCED = $00000010; // = 1 => advanced mode
  114. {$EXTERNALSYM DSPROVIDER_ADVANCED}
  115. CFSTR_DSOBJECTNAMES = 'DsObjectNames';
  116. {$EXTERNALSYM CFSTR_DSOBJECTNAMES}
  117. type
  118. LPDSOBJECT = ^DSOBJECT;
  119. {$EXTERNALSYM LPDSOBJECT}
  120. DSOBJECT = record
  121. dwFlags: DWORD; // item flags
  122. dwProviderFlags: DWORD; // flags for item provider
  123. offsetName: DWORD; // offset to ADS path of the object
  124. offsetClass: DWORD; // offset to object class name / == 0 not known
  125. end;
  126. {$EXTERNALSYM DSOBJECT}
  127. TDsObject = DSOBJECT;
  128. PDsObject = LPDSOBJECT;
  129. LPDSOBJECTNAMES = ^DSOBJECTNAMES;
  130. {$EXTERNALSYM LPDSOBJECTNAMES}
  131. DSOBJECTNAMES = record
  132. clsidNamespace: CLSID; // namespace identifier (indicates which namespace selection from)
  133. cItems: UINT; // number of objects
  134. aObjects: array [0..0] of DSOBJECT; // array of objects
  135. end;
  136. {$EXTERNALSYM DSOBJECTNAMES}
  137. TDsObjectNames = DSOBJECTNAMES;
  138. PDsObjectNames = LPDSOBJECTNAMES;
  139. //
  140. // CF_DSDISPLAYSPECOPTIONS
  141. // -----------------------
  142. // When invoking an object referenced by a display specifier (context menu, property
  143. // page, etc) we call the IShellExtInit interface passing a IDataObject. This data
  144. // object supports the CF_DSDISPLAYSPECOPTIONS format to give out configuration
  145. // informaiton about admin/shell invocation.
  146. //
  147. // When interacting with dsuiext.dll the interfaces uses this clipboard format
  148. // to determine which display specifier attributes to address (admin/shell)
  149. // and pick up the values accordingly. If no format is suppoted then
  150. // dsuiext.dll defaults to shell.
  151. //
  152. const
  153. CFSTR_DS_DISPLAY_SPEC_OPTIONS = 'DsDisplaySpecOptions';
  154. {$EXTERNALSYM CFSTR_DS_DISPLAY_SPEC_OPTIONS}
  155. CFSTR_DSDISPLAYSPECOPTIONS = CFSTR_DS_DISPLAY_SPEC_OPTIONS;
  156. {$EXTERNALSYM CFSTR_DSDISPLAYSPECOPTIONS}
  157. type
  158. LPDSDISPLAYSPECOPTIONS = ^DSDISPLAYSPECOPTIONS;
  159. {$EXTERNALSYM LPDSDISPLAYSPECOPTIONS}
  160. _DSDISPLAYSPECOPTIONS = record
  161. dwSize: DWORD; // size of struct, for versioning
  162. dwFlags: DWORD; // invocation flags
  163. offsetAttribPrefix: DWORD; // offset to attribute prefix string.
  164. offsetUserName: DWORD; // offset to UNICODE user name
  165. offsetPassword: DWORD; // offset to UNICODE password
  166. offsetServer: DWORD;
  167. offsetServerConfigPath: DWORD;
  168. end;
  169. {$EXTERNALSYM _DSDISPLAYSPECOPTIONS}
  170. DSDISPLAYSPECOPTIONS = _DSDISPLAYSPECOPTIONS;
  171. {$EXTERNALSYM DSDISPLAYSPECOPTIONS}
  172. TDsDisplaySpecOptions = DSDISPLAYSPECOPTIONS;
  173. PDsDisplaySpecOptions = LPDSDISPLAYSPECOPTIONS;
  174. const
  175. DS_PROP_SHELL_PREFIX = 'shell';
  176. {$EXTERNALSYM DS_PROP_SHELL_PREFIX}
  177. DS_PROP_ADMIN_PREFIX = 'admin';
  178. {$EXTERNALSYM DS_PROP_ADMIN_PREFIX}
  179. DSDSOF_HASUSERANDSERVERINFO = $00000001; // = 1 => user name/password are valid
  180. {$EXTERNALSYM DSDSOF_HASUSERANDSERVERINFO}
  181. DSDSOF_SIMPLEAUTHENTICATE = $00000002; // = 1 => don't use secure authentication to DS
  182. {$EXTERNALSYM DSDSOF_SIMPLEAUTHENTICATE}
  183. DSDSOF_DONTSIGNSEAL = $00000004; // = 1 => don't sign+seal when opening DS objects
  184. {$EXTERNALSYM DSDSOF_DONTSIGNSEAL}
  185. DSDSOF_DSAVAILABLE = $40000000; // = 1 => ignore DS available checks
  186. {$EXTERNALSYM DSDSOF_DSAVAILABLE}
  187. //
  188. // CF_DSPROPERTYPAGEINFO
  189. // ---------------------
  190. // When the property pages for an object are being displayed the parsed
  191. // display specifier string is passed to the page object via the IDataObject
  192. // in the following clipboard format.
  193. //
  194. // Within the display specifier for a property page, the format for a
  195. // Win32 extension is "n,{clsid}[,bla...]" we take the "bla" section and
  196. // pass it down.
  197. //
  198. CFSTR_DSPROPERTYPAGEINFO = 'DsPropPageInfo';
  199. {$EXTERNALSYM CFSTR_DSPROPERTYPAGEINFO}
  200. type
  201. LPDSPROPERTYPAGEINFO = ^DSPROPERTYPAGEINFO;
  202. {$EXTERNALSYM LPDSPROPERTYPAGEINFO}
  203. DSPROPERTYPAGEINFO = record
  204. offsetString: DWORD; // offset to UNICODE string
  205. end;
  206. {$EXTERNALSYM DSPROPERTYPAGEINFO}
  207. TDsPropertyPageInfo = DSPROPERTYPAGEINFO;
  208. PDsPropertyPageInfo = LPDSPROPERTYPAGEINFO;
  209. //
  210. // To sync property pages and the admin tools this message is broadcast
  211. //
  212. const
  213. DSPROP_ATTRCHANGED_MSG = 'DsPropAttrChanged';
  214. {$EXTERNALSYM DSPROP_ATTRCHANGED_MSG}
  215. //---------------------------------------------------------------------------//
  216. //---------------------------------------------------------------------------//
  217. //
  218. // IDsBrowseDomainTree
  219. // ===================
  220. // This interface returns a list of the domains from a given computer name
  221. // (or the current computer name if none is specified).
  222. //
  223. // NOTES:
  224. // 1) The structure returned by ::GetDomains should be free'd using
  225. // FreeDomains.
  226. //
  227. // 2) ::BrowseTo allocates a string on exit, this is allocated using
  228. // CoTaskMemAlloc, and therefore should be free'd using CoTaskMemFree.
  229. //
  230. //---------------------------------------------------------------------------//
  231. DBDTF_RETURNFQDN = $00000001; // if not set, pszNCName will be blank
  232. {$EXTERNALSYM DBDTF_RETURNFQDN}
  233. DBDTF_RETURNMIXEDDOMAINS = $00000002; // set it if you want downlevel trust domains too
  234. {$EXTERNALSYM DBDTF_RETURNMIXEDDOMAINS}
  235. DBDTF_RETURNEXTERNAL = $00000004; // set it if you want external trust domains too
  236. {$EXTERNALSYM DBDTF_RETURNEXTERNAL}
  237. DBDTF_RETURNINBOUND = $00000008; // set it if you want trusting domains
  238. {$EXTERNALSYM DBDTF_RETURNINBOUND}
  239. DBDTF_RETURNINOUTBOUND = $00000010; // set it if you want both trusted and trusting domains
  240. {$EXTERNALSYM DBDTF_RETURNINOUTBOUND}
  241. type
  242. PDOMAINDESC = ^DOMAINDESC;
  243. {$EXTERNALSYM PDOMAINDESC}
  244. _DOMAINDESC = record
  245. pszName: LPWSTR; // domain name (if no dns, use netbios)
  246. pszPath: LPWSTR; // set to blank
  247. pszNCName: LPWSTR; // FQDN, e.g.,DC=mydomain,DC=microsoft,DC=com
  248. pszTrustParent: LPWSTR; // parent domain name (if no dns, use netbios)
  249. pszObjectClass: LPWSTR; // Object class of the domain object referenced
  250. ulFlags: ULONG; // Flags, from DS_TRUSTED_DOMAINS.Flags
  251. fDownLevel: BOOL; // == 1 if downlevel domain
  252. pdChildList: PDOMAINDESC; // Children of this node
  253. pdNextSibling: PDOMAINDESC; // Siblings of this node
  254. end;
  255. {$EXTERNALSYM _DOMAINDESC}
  256. DOMAINDESC = _DOMAINDESC;
  257. {$EXTERNALSYM DOMAINDESC}
  258. TDomainDesc = DOMAINDESC;
  259. PDOMAIN_TREE = ^DOMAIN_TREE;
  260. {$EXTERNALSYM PDOMAIN_TREE}
  261. DOMAIN_TREE = record
  262. dsSize: DWORD;
  263. dwCount: DWORD;
  264. aDomains: array [0..1 - 1] of DOMAINDESC;
  265. end;
  266. {$EXTERNALSYM DOMAIN_TREE}
  267. DOMAINTREE = DOMAIN_TREE;
  268. {$EXTERNALSYM DOMAINTREE}
  269. TDomainTree = DOMAIN_TREE;
  270. PDomainTree = PDOMAIN_TREE;
  271. IDsBrowseDomainTree = interface (IUnknown)
  272. ['{7cabcf1e-78f5-11d2-960c-00c04fa31a86}']
  273. function BrowseTo(hwndParent: HWND; var ppszTargetPath: LPWSTR;
  274. dwFlags: DWORD): HRESULT; stdcall;
  275. function GetDomains(var ppDomainTree: PDOMAIN_TREE;
  276. dwFlags: DWORD): HRESULT; stdcall;
  277. function FreeDomains(var ppDomainTree: PDOMAIN_TREE): HRESULT; stdcall;
  278. function FlushCachedDomains: HRESULT; stdcall;
  279. function SetComputer(pszComputerName, pszUserName,
  280. pszPassword: LPCWSTR): HRESULT; stdcall;
  281. end;
  282. {$EXTERNALSYM IDsBrowseDomainTree}
  283. //---------------------------------------------------------------------------//
  284. //---------------------------------------------------------------------------//
  285. //
  286. // IDsDisplaySpecifier
  287. // ===================
  288. // This interface gives client UI access to the display specifiers for
  289. // specific attributes.
  290. //
  291. //---------------------------------------------------------------------------//
  292. //
  293. // IDsDisplaySpecifier::SetServer flags
  294. //
  295. const
  296. DSSSF_SIMPLEAUTHENTICATE = $00000001; // = 1 => don't use secure authentication to DS
  297. {$EXTERNALSYM DSSSF_SIMPLEAUTHENTICATE}
  298. DSSSF_DONTSIGNSEAL = $00000002; // = 1 => don't use sign+seal when opening objects in the DS
  299. {$EXTERNALSYM DSSSF_DONTSIGNSEAL}
  300. DSSSF_DSAVAILABLE = DWORD($80000000); // = 1 => ignore DS available checks
  301. {$EXTERNALSYM DSSSF_DSAVAILABLE}
  302. //
  303. // Flags for IDsDisplaySpecifier::GetIcon / GetIconLocation
  304. //
  305. DSGIF_ISNORMAL = $0000000; // = icon is in normal state (default)
  306. {$EXTERNALSYM DSGIF_ISNORMAL}
  307. DSGIF_ISOPEN = $0000001; // = icon is in open state
  308. {$EXTERNALSYM DSGIF_ISOPEN}
  309. DSGIF_ISDISABLED = $0000002; // = icon is in a disabled state
  310. {$EXTERNALSYM DSGIF_ISDISABLED}
  311. DSGIF_ISMASK = $000000f;
  312. {$EXTERNALSYM DSGIF_ISMASK}
  313. DSGIF_GETDEFAULTICON = $0000010; // = 1 => if no icon then get default (from shell32.dll)
  314. {$EXTERNALSYM DSGIF_GETDEFAULTICON}
  315. DSGIF_DEFAULTISCONTAINER = $0000020; // = 1 => if returning default icon, return it as a container
  316. {$EXTERNALSYM DSGIF_DEFAULTISCONTAINER}
  317. //
  318. // Flags for IDsDisplaySpecifier::IsClassContainer
  319. //
  320. DSICCF_IGNORETREATASLEAF = $00000001; // = 1 => igore the "treatAsLeaf" and use only schema information
  321. {$EXTERNALSYM DSICCF_IGNORETREATASLEAF}
  322. //
  323. // Callback function used for IDsDisplaySpecifier::EnumClassAttributes
  324. //
  325. DSECAF_NOTLISTED = $00000001; // = 1 => hide from the field drop down in the query UI
  326. {$EXTERNALSYM DSECAF_NOTLISTED}
  327. type
  328. LPDSENUMATTRIBUTES = function(lParam: LPARAM; pszAttributeName: LPCWSTR;
  329. pszDisplayName: LPCWSTR; dwFlags: DWORD): HRESULT; stdcall;
  330. {$EXTERNALSYM LPDSENUMATTRIBUTES}
  331. TDsEnumAttributes = LPDSENUMATTRIBUTES;
  332. //
  333. // IDsDisplaySpecifier::GetClassCreationInfo information
  334. //
  335. const
  336. DSCCIF_HASWIZARDDIALOG = $00000001; // = 1 => return the wizard dialog CLSID
  337. {$EXTERNALSYM DSCCIF_HASWIZARDDIALOG}
  338. DSCCIF_HASWIZARDPRIMARYPAGE = $00000002; // = 1 => returning a primary wizard dlg CLSID
  339. {$EXTERNALSYM DSCCIF_HASWIZARDPRIMARYPAGE}
  340. type
  341. LPDSCLASSCREATIONINFO = ^DSCLASSCREATIONINFO;
  342. {$EXTERNALSYM LPDSCLASSCREATIONINFO}
  343. DSCLASSCREATIONINFO = record
  344. dwFlags: DWORD;
  345. clsidWizardDialog: CLSID;
  346. clsidWizardPrimaryPage: CLSID;
  347. cWizardExtensions: DWORD; // how many extension CLSIDs?
  348. aWizardExtensions: array [0..0] of CLSID;
  349. end;
  350. {$EXTERNALSYM DSCLASSCREATIONINFO}
  351. TDsClassCreationInfo = DSCLASSCREATIONINFO;
  352. PDsClassCreationInfo = LPDSCLASSCREATIONINFO;
  353. //
  354. // IDsDisplaySpecifier - a COM object for interacting with display specifiers
  355. //
  356. IDsDisplaySpecifier = interface (IUnknown)
  357. ['{1ab4a8c0-6a0b-11d2-ad49-00c04fa31a86}']
  358. function SetServer(pszServer, pszUserName, pszPassword: LPCWSTR;
  359. dwFlags: DWORD): HRESULT; stdcall;
  360. function SetLanguageID(langid: LANGID): HRESULT; stdcall;
  361. function GetDisplaySpecifier(pszObjectClass: LPCWSTR; riid: LPGUID;
  362. var ppv: Pointer): HRESULT; stdcall;
  363. function GetIconLocation(pszObjectClass: LPCWSTR; dwFlags: DWORD;
  364. pszBuffer: LPWSTR; cchBuffer: Integer; var presid: Integer): HRESULT; stdcall;
  365. function GetIcon(pszObjectClass: LPCWSTR; dwFlags: DWORD;
  366. cxIcon, cyIcon: Integer): HICON; stdcall;
  367. function GetFriendlyClassName(pszObjectClass: LPCWSTR; pszBuffer: LPWSTR;
  368. cchBuffer: Integer): HRESULT; stdcall;
  369. function GetFriendlyAttributeName(pszObjectClass, pszAttributeName,
  370. pszBuffer: LPCWSTR; cchBuffer: UINT): HRESULT; stdcall;
  371. function IsClassContainer(pszObjectClass, pszADsPath: LPCWSTR;
  372. dwFlags: DWORD): BOOL; stdcall;
  373. function GetClassCreationInfo(pszObjectClass: LPCWSTR;
  374. var ppdscci: LPDSCLASSCREATIONINFO): HRESULT; stdcall;
  375. function EnumClassAttributes(pszObjectClass: LPCWSTR;
  376. pcbEnum: LPDSENUMATTRIBUTES; lParam: LPARAM): HRESULT; stdcall;
  377. function GetAttributeADsType(pszAttributeName: LPCWSTR): ADSTYPEENUM; stdcall;
  378. end;
  379. {$EXTERNALSYM IDsDisplaySpecifier}
  380. //---------------------------------------------------------------------------//
  381. //
  382. // DsBrowseForContainer
  383. // --------------------
  384. // Provides a container browser similar to the SHBrowseForFolder, except
  385. // targetting the DS.
  386. //
  387. // In:
  388. // pInfo -> DSBROWSEINFO structure
  389. //
  390. // Out:
  391. // == IDOK/IDCANCEL depending on buttons, -1 if error
  392. //
  393. //---------------------------------------------------------------------------//
  394. type
  395. BFFCALLBACK = function(hwnd: HWND; msg: UINT;
  396. lpData, lParam: LPARAM): Integer; stdcall;
  397. {$NODEFINE BFFCALLBACK}
  398. TBffCallback = BFFCALLBACK;
  399. PDSBROWSEINFOW = ^DSBROWSEINFOW;
  400. DSBROWSEINFOW = record
  401. cbStruct: DWORD; // size of structure in bytes
  402. hwndOwner: HWND; // dialog owner
  403. pszCaption: LPCWSTR; // dialog caption text (can be NULL)
  404. pszTitle: LPCWSTR; // displayed above the tree view control (can be NULL)
  405. pszRoot: LPCWSTR; // ADS path to root (NULL == root of DS namespace)
  406. pszPath: LPWSTR; // [in/out] initial selection & returned path (required)
  407. cchPath: ULONG; // size of pszPath buffer in characters
  408. dwFlags: DWORD;
  409. pfnCallback: BFFCALLBACK; // callback function(see SHBrowseForFolder)
  410. lParam: LPARAM; // passed to pfnCallback as lpUserData
  411. dwReturnFormat: DWORD; // ADS_FORMAT_* (default is ADS_FORMAT_X500_NO_SERVER)
  412. pUserName: LPCWSTR; // Username and Password to authenticate against DS with
  413. pPassword: LPCWSTR;
  414. pszObjectClass: LPWSTR; // UNICODE string for the object class
  415. cchObjectClass: ULONG;
  416. end;
  417. {$EXTERNALSYM DSBROWSEINFOW}
  418. TDsBrowseInfoW = DSBROWSEINFOW;
  419. PDSBROWSEINFOA = ^DSBROWSEINFOA;
  420. DSBROWSEINFOA = record
  421. cbStruct: DWORD;
  422. hwndOwner: HWND;
  423. pszCaption: LPCSTR;
  424. pszTitle: LPCSTR;
  425. pszRoot: LPCWSTR; // ADS paths are always UNICODE
  426. pszPath: LPWSTR; // ditto
  427. cchPath: ULONG;
  428. dwFlags: DWORD;
  429. pfnCallback: BFFCALLBACK;
  430. lParam: LPARAM;
  431. dwReturnFormat: DWORD;
  432. pUserName: LPCWSTR; // Username and Password to authenticate against DS with
  433. pPassword: LPCWSTR;
  434. pszObjectClass: LPWSTR; // object class of the selected object
  435. cchObjectClass: ULONG;
  436. end;
  437. {$EXTERNALSYM DSBROWSEINFOA}
  438. TDsBrowseInfoA = DSBROWSEINFOA;
  439. {$IFDEF UNICODE}
  440. DSBROWSEINFO = DSBROWSEINFOW;
  441. {$EXTERNALSYM DSBROWSEINFO}
  442. PDSBROWSEINFO = PDSBROWSEINFOW;
  443. {$EXTERNALSYM PDSBROWSEINFO}
  444. TDsBrowseInfo = TDsBrowseInfoW;
  445. {$ELSE}
  446. DSBROWSEINFO = DSBROWSEINFOA;
  447. {$EXTERNALSYM DSBROWSEINFO}
  448. PDSBROWSEINFO = PDSBROWSEINFOA;
  449. {$EXTERNALSYM PDSBROWSEINFO}
  450. TDsBrowseInfo = TDsBrowseInfoA;
  451. {$ENDIF UNICODE}
  452. // DSBROWSEINFO flags
  453. const
  454. DSBI_NOBUTTONS = $00000001; // NOT TVS_HASBUTTONS
  455. {$EXTERNALSYM DSBI_NOBUTTONS}
  456. DSBI_NOLINES = $00000002; // NOT TVS_HASLINES
  457. {$EXTERNALSYM DSBI_NOLINES}
  458. DSBI_NOLINESATROOT = $00000004; // NOT TVS_LINESATROOT
  459. {$EXTERNALSYM DSBI_NOLINESATROOT}
  460. DSBI_CHECKBOXES = $00000100; // TVS_CHECKBOXES
  461. {$EXTERNALSYM DSBI_CHECKBOXES}
  462. DSBI_NOROOT = $00010000; // don't include pszRoot in tree (its children become top level nodes)
  463. {$EXTERNALSYM DSBI_NOROOT}
  464. DSBI_INCLUDEHIDDEN = $00020000; // display hidden objects
  465. {$EXTERNALSYM DSBI_INCLUDEHIDDEN}
  466. DSBI_EXPANDONOPEN = $00040000; // expand to the path specified in pszPath when opening the dialog
  467. {$EXTERNALSYM DSBI_EXPANDONOPEN}
  468. DSBI_ENTIREDIRECTORY = $00090000; // browse the entire directory (defaults to having DSBI_NOROOT set)
  469. {$EXTERNALSYM DSBI_ENTIREDIRECTORY}
  470. DSBI_RETURN_FORMAT = $00100000; // dwReturnFormat field is valid
  471. {$EXTERNALSYM DSBI_RETURN_FORMAT}
  472. DSBI_HASCREDENTIALS = $00200000; // pUserName & pPassword are valid
  473. {$EXTERNALSYM DSBI_HASCREDENTIALS}
  474. DSBI_IGNORETREATASLEAF = $00400000; // ignore the treat as leaf flag when calling IsClassContainer
  475. {$EXTERNALSYM DSBI_IGNORETREATASLEAF}
  476. DSBI_SIMPLEAUTHENTICATE = $00800000; // don't use secure authentication to DS
  477. {$EXTERNALSYM DSBI_SIMPLEAUTHENTICATE}
  478. DSBI_RETURNOBJECTCLASS = $01000000; // return object class of selected object
  479. {$EXTERNALSYM DSBI_RETURNOBJECTCLASS}
  480. DSBI_DONTSIGNSEAL = $02000000; // don't sign+seal communication with DS
  481. {$EXTERNALSYM DSBI_DONTSIGNSEAL}
  482. DSB_MAX_DISPLAYNAME_CHARS = 64;
  483. {$EXTERNALSYM DSB_MAX_DISPLAYNAME_CHARS}
  484. type
  485. PDSBITEMW = ^DSBITEMW;
  486. DSBITEMW = record
  487. cbStruct: DWORD;
  488. pszADsPath: LPCWSTR; // ADS paths are always Unicode
  489. pszClass: LPCWSTR; // ADS properties are always Unicode
  490. dwMask: DWORD;
  491. dwState: DWORD;
  492. dwStateMask: DWORD;
  493. szDisplayName: array [0..DSB_MAX_DISPLAYNAME_CHARS - 1] of WCHAR;
  494. szIconLocation: array [0..MAX_PATH - 1] of WCHAR;
  495. iIconResID: Integer;
  496. end;
  497. {$EXTERNALSYM DSBITEMW}
  498. TDsBItemW = DSBITEMW;
  499. PDSBITEMA = ^DSBITEMA;
  500. DSBITEMA = record
  501. cbStruct: DWORD;
  502. pszADsPath: LPCWSTR; // ADS paths are always Unicode
  503. pszClass: LPCWSTR; // ADS properties are always Unicode
  504. dwMask: DWORD;
  505. dwState: DWORD;
  506. dwStateMask: DWORD;
  507. szDisplayName: array [0..DSB_MAX_DISPLAYNAME_CHARS - 1] of CHAR;
  508. szIconLocation: array [0..MAX_PATH - 1] of CHAR;
  509. iIconResID: Integer;
  510. end;
  511. {$EXTERNALSYM DSBITEMA}
  512. TDsBItemA = DSBITEMA;
  513. {$IFDEF UNICODE}
  514. DSBITEM = DSBITEMW;
  515. {$EXTERNALSYM DSBITEM}
  516. PDSBITEM = PDSBITEMW;
  517. {$EXTERNALSYM PDSBITEM}
  518. TDsBItem = TDsBItemW;
  519. {$ELSE}
  520. DSBITEM = DSBITEMA;
  521. {$EXTERNALSYM DSBITEM}
  522. PDSBITEM = PDSBITEMA;
  523. {$EXTERNALSYM PDSBITEM}
  524. TDsBItem = TDsBItemA;
  525. {$ENDIF UNICODE}
  526. // DSBITEM mask flags
  527. const
  528. DSBF_STATE = $00000001;
  529. {$EXTERNALSYM DSBF_STATE}
  530. DSBF_ICONLOCATION = $00000002;
  531. {$EXTERNALSYM DSBF_ICONLOCATION}
  532. DSBF_DISPLAYNAME = $00000004;
  533. {$EXTERNALSYM DSBF_DISPLAYNAME}
  534. // DSBITEM state flags
  535. DSBS_CHECKED = $00000001;
  536. {$EXTERNALSYM DSBS_CHECKED}
  537. DSBS_HIDDEN = $00000002;
  538. {$EXTERNALSYM DSBS_HIDDEN}
  539. DSBS_ROOT = $00000004;
  540. {$EXTERNALSYM DSBS_ROOT}
  541. //
  542. // this message is sent to the callback to see if it wants to insert or modify
  543. // the item that is about to be inserted into the view.
  544. //
  545. DSBM_QUERYINSERTW = 100; // lParam = PDSBITEMW (state, icon & name may be modified). Return TRUE if handled.
  546. {$EXTERNALSYM DSBM_QUERYINSERTW}
  547. DSBM_QUERYINSERTA = 101; // lParam = PDSBITEMA (state, icon & name may be modified). Return TRUE if handled.
  548. {$EXTERNALSYM DSBM_QUERYINSERTA}
  549. {$IFDEF UNICODE}
  550. DSBM_QUERYINSERT = DSBM_QUERYINSERTW;
  551. {$EXTERNALSYM DSBM_QUERYINSERT}
  552. {$ELSE}
  553. DSBM_QUERYINSERT = DSBM_QUERYINSERTA;
  554. {$EXTERNALSYM DSBM_QUERYINSERT}
  555. {$ENDIF UNICODE}
  556. //
  557. // Called before we change the state of the icon (on tree collapse/expand)
  558. //
  559. DSBM_CHANGEIMAGESTATE = 102; // lParam = adspath. Return TRUE/FALSE top allow/disallow
  560. {$EXTERNALSYM DSBM_CHANGEIMAGESTATE}
  561. //
  562. // The dialog receives a WM_HELP
  563. //
  564. DSBM_HELP = 103; // lParam == LPHELPINFO structure
  565. {$EXTERNALSYM DSBM_HELP}
  566. //
  567. // The dialog receives a WM_CONTEXTMENU, DSBID_xxx are the control ID's for this
  568. // dialog so that you can display suitable help.
  569. //
  570. DSBM_CONTEXTMENU = 104; // lParam == window handle to retrieve help for
  571. {$EXTERNALSYM DSBM_CONTEXTMENU}
  572. //
  573. // These are the control IDs for the controls in the dialog. The callback can use
  574. // these to modify the contents of the dialog as required.
  575. //
  576. DSBID_BANNER = 256;
  577. {$EXTERNALSYM DSBID_BANNER}
  578. DSBID_CONTAINERLIST = 257;
  579. {$EXTERNALSYM DSBID_CONTAINERLIST}
  580. //
  581. // API exported for browsing for containers.
  582. //
  583. function DsBrowseForContainerW(const pInfo: DSBROWSEINFOW): Integer; stdcall;
  584. {$EXTERNALSYM DsBrowseForContainerW}
  585. function DsBrowseForContainerA(const pInfo: DSBROWSEINFOA): Integer; stdcall;
  586. {$EXTERNALSYM DsBrowseForContainerA}
  587. function DsBrowseForContainer(const pInfo: DSBROWSEINFO): Integer; stdcall;
  588. {$EXTERNALSYM DsBrowseForContainer}
  589. //BUGBUG: these are here to keep old clients building - remove soon
  590. function DsGetIcon(dwFlags: DWORD; pszObjectClass: LPWSTR;
  591. cxImage, cyImage: Integer): HICON; stdcall;
  592. {$EXTERNALSYM DsGetIcon}
  593. procedure DsGetFriendlyClassName(pszObjectClass, pszBuffer: LPWSTR;
  594. cchBuffer: UINT); stdcall;
  595. {$EXTERNALSYM DsGetFriendlyClassName}
  596. implementation
  597. const
  598. dsuiext = 'dsuiext.dll';
  599. {$IFDEF UNICODE}
  600. AWSuffix = 'W';
  601. {$ELSE}
  602. AWSuffix = 'A';
  603. {$ENDIF UNICODE}
  604. {$IFDEF DYNAMIC_LINK}
  605. var
  606. _DsBrowseForContainerW: Pointer;
  607. function DsBrowseForContainerW;
  608. begin
  609. GetProcedureAddress(_DsBrowseForContainerW, dsuiext, 'DsBrowseForContainerW');
  610. asm
  611. MOV ESP, EBP
  612. POP EBP
  613. JMP [_DsBrowseForContainerW]
  614. end;
  615. end;
  616. var
  617. _DsBrowseForContainerA: Pointer;
  618. function DsBrowseForContainerA;
  619. begin
  620. GetProcedureAddress(_DsBrowseForContainerA, dsuiext, 'DsBrowseForContainerA');
  621. asm
  622. MOV ESP, EBP
  623. POP EBP
  624. JMP [_DsBrowseForContainerA]
  625. end;
  626. end;
  627. var
  628. _DsBrowseForContainer: Pointer;
  629. function DsBrowseForContainer;
  630. begin
  631. GetProcedureAddress(_DsBrowseForContainer, dsuiext, 'DsBrowseForContainer' + AWSuffix);
  632. asm
  633. MOV ESP, EBP
  634. POP EBP
  635. JMP [_DsBrowseForContainer]
  636. end;
  637. end;
  638. var
  639. _DsGetIcon: Pointer;
  640. function DsGetIcon;
  641. begin
  642. GetProcedureAddress(_DsGetIcon, dsuiext, 'DsGetIcon');
  643. asm
  644. MOV ESP, EBP
  645. POP EBP
  646. JMP [_DsGetIcon]
  647. end;
  648. end;
  649. var
  650. _DsGetFriendlyClassName: Pointer;
  651. procedure DsGetFriendlyClassName;
  652. begin
  653. GetProcedureAddress(_DsGetFriendlyClassName, dsuiext, 'DsGetFriendlyClassName');
  654. asm
  655. MOV ESP, EBP
  656. POP EBP
  657. JMP [_DsGetFriendlyClassName]
  658. end;
  659. end;
  660. {$ELSE}
  661. function DsBrowseForContainerW; external dsuiext name 'DsBrowseForContainerW';
  662. function DsBrowseForContainerA; external dsuiext name 'DsBrowseForContainerA';
  663. function DsBrowseForContainer; external dsuiext name 'DsBrowseForContainer' + AWSuffix;
  664. function DsGetIcon; external dsuiext name 'DsGetIcon';
  665. procedure DsGetFriendlyClassName; external dsuiext name 'DsGetFriendlyClassName';
  666. {$ENDIF DYNAMIC_LINK}
  667. end.