jwaadsprop.pas 15 KB

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