jwadsclient.pas 27 KB

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