jwaadsprop.pas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. {******************************************************************************}
  2. { }
  3. { Active Directory Property Pages 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: adsprop.h, released June 2000. The original Pascal }
  9. { code is: AdsProp.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: JwaAdsProp.pas,v 1.13 2007/09/06 14:57:10 marquardt Exp $
  43. {$IFNDEF JWA_OMIT_SECTIONS}
  44. unit JwaAdsProp;
  45. {$WEAKPACKAGEUNIT}
  46. {$ENDIF JWA_OMIT_SECTIONS}
  47. {$HPPEMIT ''}
  48. {$HPPEMIT '#include "adsprop.h"'}
  49. {$HPPEMIT ''}
  50. {$IFNDEF JWA_OMIT_SECTIONS}
  51. {$I jediapilib.inc}
  52. interface
  53. uses
  54. JwaActiveX, JwaAdsTLB, JwaWinUser, JwaWinType;
  55. {$ENDIF JWA_OMIT_SECTIONS}
  56. {$IFNDEF JWA_IMPLEMENTATIONSECTION}
  57. // Windows NT Active Directory Service Property Pages
  58. //
  59. // Contents: Functions and definitions used in the creation of AD property
  60. // sheets.
  61. const
  62. {$IFNDEF JWA_INCLUDEMODE}
  63. WM_ADSPROP_NOTIFY_PAGEINIT = WM_USER + 1101; // where LPARAM is the PADSPROPINITPARAMS pointer.
  64. {$EXTERNALSYM WM_ADSPROP_NOTIFY_PAGEINIT}
  65. WM_ADSPROP_NOTIFY_PAGEHWND = WM_USER + 1102; // where WPARAM => page's HWND and LPARAM => page's Title
  66. {$EXTERNALSYM WM_ADSPROP_NOTIFY_PAGEHWND}
  67. WM_ADSPROP_NOTIFY_CHANGE = WM_USER + 1103; // used to send a change notification to a parent sheet
  68. {$EXTERNALSYM WM_ADSPROP_NOTIFY_CHANGE}
  69. WM_ADSPROP_NOTIFY_APPLY = WM_USER + 1104; // pages send this to the notification object.
  70. {$EXTERNALSYM WM_ADSPROP_NOTIFY_APPLY}
  71. WM_ADSPROP_NOTIFY_SETFOCUS = WM_USER + 1105; // used internally by the notification object.
  72. {$EXTERNALSYM WM_ADSPROP_NOTIFY_SETFOCUS}
  73. WM_ADSPROP_NOTIFY_FOREGROUND = WM_USER + 1106; // used internally by the notification object.
  74. {$EXTERNALSYM WM_ADSPROP_NOTIFY_FOREGROUND}
  75. WM_ADSPROP_NOTIFY_EXIT = WM_USER + 1107; // sent on page release
  76. {$EXTERNALSYM WM_ADSPROP_NOTIFY_EXIT}
  77. {$ENDIF JWA_INCLUDEMODE}
  78. WM_ADSPROP_NOTIFY_ERROR = WM_USER + 1110; // used to send the notification object an error message
  79. {$EXTERNALSYM WM_ADSPROP_NOTIFY_ERROR}
  80. //+----------------------------------------------------------------------------
  81. //
  82. // Structure: ADSPROPINITPARAMS
  83. //
  84. // Usage: Used to pass page initialization information to new pages from
  85. // the notify object.
  86. //
  87. //-----------------------------------------------------------------------------
  88. type
  89. {$IFNDEF JWA_INCLUDEMODE}
  90. // imports of a type library sometimes are missing a few decls, these are just
  91. // a few of them to make this file compile at all. I really should do all of
  92. // them one day. TODO
  93. PADSVALUE = ^_adsvalue;
  94. {$EXTERNALSYM PADSVALUE}
  95. PADS_ATTR_INFO = ^_ads_attr_info;
  96. {$EXTERNALSYM PADS_ATTR_INFO}
  97. PADSPROPINITPARAMS = ^ADSPROPINITPARAMS;
  98. {$EXTERNALSYM PADSPROPINITPARAMS}
  99. _ADSPROPINITPARAMS = record
  100. dwSize: DWORD; // Set this to the size of the struct.
  101. dwFlags: DWORD; // Reserved for future use.
  102. hr: HRESULT; // If this is non-zero, then the others
  103. pDsObj: IDirectoryObject; // should be ignored.
  104. pwzCN: LPWSTR;
  105. pWritableAttrs: PADS_ATTR_INFO;
  106. end;
  107. {$EXTERNALSYM _ADSPROPINITPARAMS}
  108. ADSPROPINITPARAMS = _ADSPROPINITPARAMS;
  109. {$EXTERNALSYM ADSPROPINITPARAMS}
  110. TAdsPropInitParams = ADSPROPINITPARAMS;
  111. {$ENDIF JWA_INCLUDEMODE}
  112. //+----------------------------------------------------------------------------
  113. //
  114. // Structure: ADSPROPERROR
  115. //
  116. // Usage: Used to pass page error information to the notify object
  117. //
  118. //-----------------------------------------------------------------------------
  119. _ADSPROPERROR = record
  120. hwndPage: HWND; // The HWND of the page that had the error
  121. pszPageTitle: PWSTR; // The title of the page that had the error
  122. pszObjPath: PWSTR; // Path to the object that the error occurred on
  123. pszObjClass: PWSTR; // Class of the object that the error occurred on
  124. hr: HRESULT; // If this is non-zero, then the others
  125. // pszError will be ignored
  126. pszError: PWSTR; // An error message. Used only if hr is zero
  127. end;
  128. {$EXTERNALSYM _ADSPROPERROR}
  129. ADSPROPERROR = _ADSPROPERROR;
  130. {$EXTERNALSYM ADSPROPERROR}
  131. PADSPROPERROR = ^ADSPROPERROR;
  132. {$EXTERNALSYM PADSPROPERROR}
  133. TAdsPropError = ADSPROPERROR;
  134. {$IFNDEF JWA_INCLUDEMODE}
  135. //+----------------------------------------------------------------------------
  136. //
  137. // Function: ADsPropCreateNotifyObj
  138. //
  139. // Synopsis: Checks to see if the notification window/object exists for this
  140. // sheet instance and if not creates it.
  141. //
  142. // Arguments: [pAppThdDataObj] - the unmarshalled data object pointer.
  143. // [pwzADsObjName] - object path name.
  144. // [phNotifyObj] - to return the notificion window handle.
  145. //
  146. // Returns: HRESULTs.
  147. //
  148. //-----------------------------------------------------------------------------
  149. function ADsPropCreateNotifyObj(pAppThdDataObj: Pointer{LPDATAOBJECT};
  150. pwzADsObjName: PWSTR; var phNotifyObj: HWND): HRESULT; stdcall;
  151. {$EXTERNALSYM ADsPropCreateNotifyObj}
  152. //+----------------------------------------------------------------------------
  153. //
  154. // Function: ADsPropGetInitInfo
  155. //
  156. // Synopsis: Pages call this at their init time to retreive DS object info.
  157. //
  158. // Arguments: [hNotifyObj] - the notificion window handle.
  159. // [pInitParams] - struct filled in with DS object info. This
  160. // struct must be allocated by the caller before
  161. // the call.
  162. //
  163. // Returns: FALSE if the notify window has gone away for some reason or
  164. // if the parameters are invalid.
  165. //
  166. // Notes: This call results in the sending of the
  167. // WM_ADSPROP_NOTIFY_PAGEINIT message to the notify window.
  168. // pInitParams->pWritableAttrs can be NULL if there are no
  169. // writable attributes.
  170. //
  171. //-----------------------------------------------------------------------------
  172. function ADsPropGetInitInfo(hNotifyObj: HWND; pInitParams: PADSPROPINITPARAMS): BOOL; stdcall;
  173. {$EXTERNALSYM ADsPropGetInitInfo}
  174. //+----------------------------------------------------------------------------
  175. //
  176. // Function: ADsPropSetHwndWithTitle
  177. //
  178. // Synopsis: Pages call this at their dialog init time to send their hwnd
  179. // to the Notify object.
  180. //
  181. // Arguments: [hNotifyObj] - the notificion window handle.
  182. // [hPage] - the page's window handle.
  183. // [ptzTitle] - the page's title
  184. //
  185. // Returns: FALSE if the notify window has gone away for some reason.
  186. //
  187. // Notes: Sends the WM_ADSPROP_NOTIFY_PAGEHWND message to the notify
  188. // window. Use this function instead of ADsPropSetHwnd for
  189. // multi-select property pages
  190. //
  191. //-----------------------------------------------------------------------------
  192. function ADsPropSetHwndWithTitle(hNotifyObj, hPage: HWND; ptzTitle: PTSTR): BOOL; stdcall;
  193. {$EXTERNALSYM ADsPropSetHwndWithTitle}
  194. //+----------------------------------------------------------------------------
  195. //
  196. // Function: ADsPropSetHwnd
  197. //
  198. // Synopsis: Pages call this at their dialog init time to send their hwnd
  199. // to the Notify object.
  200. //
  201. // Arguments: [hNotifyObj] - the notificion window handle.
  202. // [hPage] - the page's window handle.
  203. // [ptzTitle] - the page's title
  204. //
  205. // Returns: FALSE if the notify window has gone away for some reason.
  206. //
  207. // Notes: Sends the WM_ADSPROP_NOTIFY_PAGEHWND message to the notify
  208. // window.
  209. //
  210. //-----------------------------------------------------------------------------
  211. function ADsPropSetHwnd(hNotifyObj: HWND; hPage: HWND): BOOL; stdcall;
  212. {$EXTERNALSYM ADsPropSetHwnd}
  213. //+----------------------------------------------------------------------------
  214. //
  215. // function: ADsPropCheckIfWritable
  216. //
  217. // Synopsis: See if the attribute is writable by checking if it is in
  218. // the allowedAttributesEffective array.
  219. //
  220. // Arguments: [pwzAttr] - the attribute name.
  221. // [pWritableAttrs] - the array of writable attributes.
  222. //
  223. // Returns: FALSE if the attribute name is not found in the writable-attrs
  224. // array or if the array pointer is NULL.
  225. //
  226. //-----------------------------------------------------------------------------
  227. function ADsPropCheckIfWritable(pwzAttr: PWSTR; pWritableAttrs: PADS_ATTR_INFO): BOOL; stdcall;
  228. {$EXTERNALSYM ADsPropCheckIfWritable}
  229. //+----------------------------------------------------------------------------
  230. //
  231. // function: ADsPropSendErrorMessage
  232. //
  233. // Synopsis: Adds an error message to a list which is presented when
  234. // ADsPropShowErrorDialog is called
  235. //
  236. // Arguments: [hNotifyObj] - the notificion window handle.
  237. // [pError] - the error structure
  238. //
  239. // Returns: FALSE if the notify window has gone away for some reason.
  240. //
  241. //-----------------------------------------------------------------------------
  242. function ADsPropSendErrorMessage(hNotifyObj: HWND; pError: PADSPROPERROR): BOOL; stdcall;
  243. {$EXTERNALSYM ADsPropSendErrorMessage}
  244. //+----------------------------------------------------------------------------
  245. //
  246. // function: ADsPropShowErrorDialog
  247. //
  248. // Synopsis: Presents an error dialog with the error messages accumulated
  249. // through calls to ADsPropSendErrorMessage
  250. //
  251. // Arguments: [hNotifyObj] - the notificion window handle.
  252. // [hPage] - the property page window handle.
  253. //
  254. // Returns: FALSE if the notify window has gone away for some reason.
  255. //
  256. //-----------------------------------------------------------------------------
  257. function ADsPropShowErrorDialog(hNotifyObj: HWND; hPage: HWND): BOOL; stdcall;
  258. {$EXTERNALSYM ADsPropShowErrorDialog}
  259. {$ENDIF JWA_INCLUDEMODE}
  260. {$ENDIF JWA_IMPLEMENTATIONSECTION}
  261. {$IFNDEF JWA_OMIT_SECTIONS}
  262. implementation
  263. //uses ...
  264. {$ENDIF JWA_OMIT_SECTIONS}
  265. {$IFNDEF JWA_INTERFACESECTION}
  266. {$IFNDEF JWA_INCLUDEMODE}
  267. const
  268. dsprop = 'dsprop.dll';
  269. {$ENDIF JWA_INCLUDEMODE}
  270. {$IFDEF DYNAMIC_LINK}
  271. {$IFNDEF JWA_INCLUDEMODE}
  272. var
  273. _ADsPropCreateNotifyObj: Pointer;
  274. function ADsPropCreateNotifyObj;
  275. begin
  276. GetProcedureAddress(_ADsPropCreateNotifyObj, dsprop, 'ADsPropCreateNotifyObj');
  277. asm
  278. MOV ESP, EBP
  279. POP EBP
  280. JMP [_ADsPropCreateNotifyObj]
  281. end;
  282. end;
  283. var
  284. _ADsPropGetInitInfo: Pointer;
  285. function ADsPropGetInitInfo;
  286. begin
  287. GetProcedureAddress(_ADsPropGetInitInfo, dsprop, 'ADsPropGetInitInfo');
  288. asm
  289. MOV ESP, EBP
  290. POP EBP
  291. JMP [_ADsPropGetInitInfo]
  292. end;
  293. end;
  294. var
  295. _ADsPropSetHwndWithTitle: Pointer;
  296. function ADsPropSetHwndWithTitle;
  297. begin
  298. GetProcedureAddress(_ADsPropSetHwndWithTitle, dsprop, 'ADsPropSetHwndWithTitle');
  299. asm
  300. MOV ESP, EBP
  301. POP EBP
  302. JMP [_ADsPropSetHwndWithTitle]
  303. end;
  304. end;
  305. var
  306. _ADsPropSetHwnd: Pointer;
  307. function ADsPropSetHwnd;
  308. begin
  309. GetProcedureAddress(_ADsPropSetHwnd, dsprop, 'ADsPropSetHwnd');
  310. asm
  311. MOV ESP, EBP
  312. POP EBP
  313. JMP [_ADsPropSetHwnd]
  314. end;
  315. end;
  316. var
  317. _ADsPropCheckIfWritable: Pointer;
  318. function ADsPropCheckIfWritable;
  319. begin
  320. GetProcedureAddress(_ADsPropCheckIfWritable, dsprop, 'ADsPropCheckIfWritable');
  321. asm
  322. MOV ESP, EBP
  323. POP EBP
  324. JMP [_ADsPropCheckIfWritable]
  325. end;
  326. end;
  327. var
  328. _ADsPropSendErrorMessage: Pointer;
  329. function ADsPropSendErrorMessage;
  330. begin
  331. GetProcedureAddress(_ADsPropSendErrorMessage, dsprop, 'ADsPropSendErrorMessage');
  332. asm
  333. MOV ESP, EBP
  334. POP EBP
  335. JMP [_ADsPropSendErrorMessage]
  336. end;
  337. end;
  338. var
  339. _ADsPropShowErrorDialog: Pointer;
  340. function ADsPropShowErrorDialog;
  341. begin
  342. GetProcedureAddress(_ADsPropShowErrorDialog, dsprop, 'ADsPropShowErrorDialog');
  343. asm
  344. MOV ESP, EBP
  345. POP EBP
  346. JMP [_ADsPropShowErrorDialog]
  347. end;
  348. end;
  349. {$ENDIF JWA_INCLUDEMODE}
  350. {$ELSE}
  351. {$IFNDEF JWA_INCLUDEMODE}
  352. function ADsPropCreateNotifyObj; external dsprop name 'ADsPropCreateNotifyObj';
  353. function ADsPropGetInitInfo; external dsprop name 'ADsPropGetInitInfo';
  354. function ADsPropSetHwndWithTitle; external dsprop name 'ADsPropSetHwndWithTitle';
  355. function ADsPropSetHwnd; external dsprop name 'ADsPropSetHwnd';
  356. function ADsPropCheckIfWritable; external dsprop name 'ADsPropCheckIfWritable';
  357. function ADsPropSendErrorMessage; external dsprop name 'ADsPropSendErrorMessage';
  358. function ADsPropShowErrorDialog; external dsprop name 'ADsPropShowErrorDialog';
  359. {$ENDIF JWA_INCLUDEMODE}
  360. {$ENDIF DYNAMIC_LINK}
  361. {$ENDIF JWA_INTERFACESECTION}
  362. {$IFNDEF JWA_OMIT_SECTIONS}
  363. end.
  364. {$ENDIF JWA_OMIT_SECTIONS}