jwalmalert.pas 9.5 KB

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