jwalmalert.pas 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. {******************************************************************************}
  2. { }
  3. { Lan Manager Alterter 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: lmalert.h, released November 2001. The original Pascal }
  9. { code is: LmAlert.pas, released Februari 2002. 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: JwaLmAlert.pas,v 1.10 2005/09/07 09:54:54 marquardt Exp $
  43. {$IFNDEF JWA_INCLUDEMODE}
  44. unit JwaLmAlert;
  45. {$WEAKPACKAGEUNIT}
  46. {$I jediapilib.inc}
  47. interface
  48. uses
  49. JwaWindows, JwaLmCons;
  50. {$ENDIF !JWA_INCLUDEMODE}
  51. {$IFDEF JWA_INTERFACESECTION}
  52. {$HPPEMIT ''}
  53. {$HPPEMIT '#include "lmalert.h"'}
  54. {$HPPEMIT ''}
  55. //
  56. // Function Prototypes
  57. //
  58. function NetAlertRaise(AlertEventName: LPCWSTR; Buffer: LPVOID; BufferSize: DWORD): NET_API_STATUS; stdcall;
  59. {$EXTERNALSYM NetAlertRaise}
  60. function NetAlertRaiseEx(AlertEventName: LPCWSTR; VariableInfo: LPVOID; VariableInfoSize: DWORD; ServiceName: LPCWSTR): NET_API_STATUS; stdcall;
  61. {$EXTERNALSYM NetAlertRaiseEx}
  62. //
  63. // Data Structures
  64. //
  65. type
  66. _STD_ALERT = record
  67. alrt_timestamp: DWORD;
  68. alrt_eventname: array [0..EVLEN] of WCHAR;
  69. alrt_servicename: array [0..SNLEN] of WCHAR;
  70. end;
  71. {$EXTERNALSYM _STD_ALERT}
  72. STD_ALERT = _STD_ALERT;
  73. {$EXTERNALSYM STD_ALERT}
  74. PSTD_ALERT = ^STD_ALERT;
  75. {$EXTERNALSYM PSTD_ALERT}
  76. LPSTD_ALERT = ^STD_ALERT;
  77. {$EXTERNALSYM LPSTD_ALERT}
  78. TStdAlert = STD_ALERT;
  79. PStdAlert = PSTD_ALERT;
  80. _ADMIN_OTHER_INFO = record
  81. alrtad_errcode: DWORD;
  82. alrtad_numstrings: DWORD;
  83. end;
  84. {$EXTERNALSYM _ADMIN_OTHER_INFO}
  85. ADMIN_OTHER_INFO = _ADMIN_OTHER_INFO;
  86. {$EXTERNALSYM ADMIN_OTHER_INFO}
  87. PADMIN_OTHER_INFO = ^ADMIN_OTHER_INFO;
  88. {$EXTERNALSYM PADMIN_OTHER_INFO}
  89. LPADMIN_OTHER_INFO = ^ADMIN_OTHER_INFO;
  90. {$EXTERNALSYM LPADMIN_OTHER_INFO}
  91. TAdminOtherInfo = ADMIN_OTHER_INFO;
  92. PAdminOtherInfo = PADMIN_OTHER_INFO;
  93. _ERRLOG_OTHER_INFO = record
  94. alrter_errcode: DWORD;
  95. alrter_offset: DWORD;
  96. end;
  97. {$EXTERNALSYM _ERRLOG_OTHER_INFO}
  98. ERRLOG_OTHER_INFO = _ERRLOG_OTHER_INFO;
  99. {$EXTERNALSYM ERRLOG_OTHER_INFO}
  100. PERRLOG_OTHER_INFO = ^ERRLOG_OTHER_INFO;
  101. {$EXTERNALSYM PERRLOG_OTHER_INFO}
  102. LPERRLOG_OTHER_INFO = ^ERRLOG_OTHER_INFO;
  103. {$EXTERNALSYM LPERRLOG_OTHER_INFO}
  104. TErrlogOtherInfo = ERRLOG_OTHER_INFO;
  105. PErrlogOtherInfo = PERRLOG_OTHER_INFO;
  106. _PRINT_OTHER_INFO = record
  107. alrtpr_jobid: DWORD;
  108. alrtpr_status: DWORD;
  109. alrtpr_submitted: DWORD;
  110. alrtpr_size: DWORD;
  111. end;
  112. {$EXTERNALSYM _PRINT_OTHER_INFO}
  113. PRINT_OTHER_INFO = _PRINT_OTHER_INFO;
  114. {$EXTERNALSYM PRINT_OTHER_INFO}
  115. PPRINT_OTHER_INFO = ^PRINT_OTHER_INFO;
  116. {$EXTERNALSYM PPRINT_OTHER_INFO}
  117. LPPRINT_OTHER_INFO = ^PRINT_OTHER_INFO;
  118. {$EXTERNALSYM LPPRINT_OTHER_INFO}
  119. TPrintOtherInfo = PRINT_OTHER_INFO;
  120. PPrintOtherInfo = PPRINT_OTHER_INFO;
  121. _USER_OTHER_INFO = record
  122. alrtus_errcode: DWORD;
  123. alrtus_numstrings: DWORD;
  124. end;
  125. {$EXTERNALSYM _USER_OTHER_INFO}
  126. USER_OTHER_INFO = _USER_OTHER_INFO;
  127. {$EXTERNALSYM USER_OTHER_INFO}
  128. PUSER_OTHER_INFO = ^USER_OTHER_INFO;
  129. {$EXTERNALSYM PUSER_OTHER_INFO}
  130. LPUSER_OTHER_INFO = ^USER_OTHER_INFO;
  131. {$EXTERNALSYM LPUSER_OTHER_INFO}
  132. TUserOtherInfo = USER_OTHER_INFO;
  133. PUserOtherInfo = PUSER_OTHER_INFO;
  134. //
  135. // Special Values and Constants
  136. //
  137. //
  138. // Name of mailslot to send alert notifications
  139. //
  140. const
  141. ALERTER_MAILSLOT = WideString('\\.\MAILSLOT\Alerter');
  142. {$EXTERNALSYM ALERTER_MAILSLOT}
  143. //
  144. // The following macro gives a pointer to the other_info data.
  145. // It takes an alert structure and returns a pointer to structure
  146. // beyond the standard portion.
  147. //
  148. function ALERT_OTHER_INFO(x: Pointer): Pointer;
  149. {$EXTERNALSYM ALERT_OTHER_INFO}
  150. //
  151. // The following macro gives a pointer to the variable-length data.
  152. // It takes a pointer to one of the other-info structs and returns a
  153. // pointer to the variable data portion.
  154. //
  155. // (rom) cannot be implemented in Delphi
  156. //function ALERT_VAR_DATA(const p): Pointer;
  157. //
  158. // Names of standard Microsoft-defined alert events.
  159. //
  160. const
  161. ALERT_PRINT_EVENT = WideString('PRINTING');
  162. {$EXTERNALSYM ALERT_PRINT_EVENT}
  163. ALERT_MESSAGE_EVENT = WideString('MESSAGE');
  164. {$EXTERNALSYM ALERT_MESSAGE_EVENT}
  165. ALERT_ERRORLOG_EVENT = WideString('ERRORLOG');
  166. {$EXTERNALSYM ALERT_ERRORLOG_EVENT}
  167. ALERT_ADMIN_EVENT = WideString('ADMIN');
  168. {$EXTERNALSYM ALERT_ADMIN_EVENT}
  169. ALERT_USER_EVENT = WideString('USER');
  170. {$EXTERNALSYM ALERT_USER_EVENT}
  171. //
  172. // Bitmap masks for prjob_status field of PRINTJOB.
  173. //
  174. // 2-7 bits also used in device status
  175. PRJOB_QSTATUS = $3; // Bits 0,1
  176. {$EXTERNALSYM PRJOB_QSTATUS}
  177. PRJOB_DEVSTATUS = $1fc; // 2-8 bits
  178. {$EXTERNALSYM PRJOB_DEVSTATUS}
  179. PRJOB_COMPLETE = $4; // Bit 2
  180. {$EXTERNALSYM PRJOB_COMPLETE}
  181. PRJOB_INTERV = $8; // Bit 3
  182. {$EXTERNALSYM PRJOB_INTERV}
  183. PRJOB_ERROR = $10; // Bit 4
  184. {$EXTERNALSYM PRJOB_ERROR}
  185. PRJOB_DESTOFFLINE = $20; // Bit 5
  186. {$EXTERNALSYM PRJOB_DESTOFFLINE}
  187. PRJOB_DESTPAUSED = $40; // Bit 6
  188. {$EXTERNALSYM PRJOB_DESTPAUSED}
  189. PRJOB_NOTIFY = $80; // BIT 7
  190. {$EXTERNALSYM PRJOB_NOTIFY}
  191. PRJOB_DESTNOPAPER = $100; // BIT 8
  192. {$EXTERNALSYM PRJOB_DESTNOPAPER}
  193. PRJOB_DELETED = $8000; // BIT 15
  194. {$EXTERNALSYM PRJOB_DELETED}
  195. //
  196. // Values of PRJOB_QSTATUS bits in prjob_status field of PRINTJOB.
  197. //
  198. PRJOB_QS_QUEUED = 0;
  199. {$EXTERNALSYM PRJOB_QS_QUEUED}
  200. PRJOB_QS_PAUSED = 1;
  201. {$EXTERNALSYM PRJOB_QS_PAUSED}
  202. PRJOB_QS_SPOOLING = 2;
  203. {$EXTERNALSYM PRJOB_QS_SPOOLING}
  204. PRJOB_QS_PRINTING = 3;
  205. {$EXTERNALSYM PRJOB_QS_PRINTING}
  206. {$ENDIF JWA_INTERFACESECTION}
  207. {$IFNDEF JWA_INCLUDEMODE}
  208. implementation
  209. uses
  210. JwaWinDLLNames;
  211. {$ENDIF !JWA_INCLUDEMODE}
  212. {$IFDEF JWA_IMPLEMENTATIONSECTION}
  213. function ALERT_OTHER_INFO(x: Pointer): Pointer;
  214. begin
  215. Result := Pointer(PChar(x) + SizeOf(STD_ALERT));
  216. end;
  217. {$IFDEF DYNAMIC_LINK}
  218. var
  219. _NetAlertRaise: Pointer;
  220. function NetAlertRaise;
  221. begin
  222. GetProcedureAddress(_NetAlertRaise, netapi32, 'NetAlertRaise');
  223. asm
  224. MOV ESP, EBP
  225. POP EBP
  226. JMP [_NetAlertRaise]
  227. end;
  228. end;
  229. var
  230. _NetAlertRaiseEx: Pointer;
  231. function NetAlertRaiseEx;
  232. begin
  233. GetProcedureAddress(_NetAlertRaiseEx, netapi32, 'NetAlertRaiseEx');
  234. asm
  235. MOV ESP, EBP
  236. POP EBP
  237. JMP [_NetAlertRaiseEx]
  238. end;
  239. end;
  240. {$ELSE}
  241. function NetAlertRaise; external netapi32 name 'NetAlertRaise';
  242. function NetAlertRaiseEx; external netapi32 name 'NetAlertRaiseEx';
  243. {$ENDIF DYNAMIC_LINK}
  244. {$ENDIF JWA_IMPLEMENTATIONSECTION}
  245. {$IFNDEF JWA_INCLUDEMODE}
  246. end.
  247. {$ENDIF !JWA_INCLUDEMODE}