jwadsclient.pas 28 KB

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