jwaadsprop.pas 15 KB

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