jwalmat.pas 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. {******************************************************************************}
  2. { }
  3. { Lan Manager Scheduler 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: lmat.h, released November 2001. The original Pascal }
  9. { code is: LmAt.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. unit JwaLmAt;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "lmat.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaLmCons, JwaWinType;
  51. //
  52. // The following bits are used with Flags field in structures below.
  53. //
  54. //
  55. // Do we exec programs for this job periodically (/EVERY switch)
  56. // or one time (/NEXT switch).
  57. //
  58. const
  59. JOB_RUN_PERIODICALLY = $01; // set if EVERY
  60. {$EXTERNALSYM JOB_RUN_PERIODICALLY}
  61. //
  62. // Was there an error last time we tried to exec a program on behalf of
  63. // this job.
  64. // This flag is meaningfull on output only!
  65. //
  66. JOB_EXEC_ERROR = $02; // set if error
  67. {$EXTERNALSYM JOB_EXEC_ERROR}
  68. //
  69. // Will this job run today or tomorrow.
  70. // This flag is meaningfull on output only!
  71. //
  72. JOB_RUNS_TODAY = $04; // set if today
  73. {$EXTERNALSYM JOB_RUNS_TODAY}
  74. //
  75. // Add current day of the month to DaysOfMonth input.
  76. // This flag is meaningfull on input only!
  77. //
  78. JOB_ADD_CURRENT_DATE = $08; // set if to add current date
  79. {$EXTERNALSYM JOB_ADD_CURRENT_DATE}
  80. //
  81. // Will this job be run interactively or not. Windows NT 3.1 do not
  82. // know about this bit, i.e. they submit interactive jobs only.
  83. //
  84. JOB_NONINTERACTIVE = $10; // set for noninteractive
  85. {$EXTERNALSYM JOB_NONINTERACTIVE}
  86. JOB_INPUT_FLAGS = JOB_RUN_PERIODICALLY or JOB_ADD_CURRENT_DATE or JOB_NONINTERACTIVE;
  87. {$EXTERNALSYM JOB_INPUT_FLAGS}
  88. JOB_OUTPUT_FLAGS = JOB_RUN_PERIODICALLY or JOB_EXEC_ERROR or JOB_RUNS_TODAY or JOB_NONINTERACTIVE;
  89. {$EXTERNALSYM JOB_OUTPUT_FLAGS}
  90. type
  91. _AT_INFO = record
  92. JobTime: DWORD_PTR;
  93. DaysOfMonth: DWORD;
  94. DaysOfWeek: UCHAR;
  95. Flags: UCHAR;
  96. Command: LPWSTR;
  97. end;
  98. {$EXTERNALSYM _AT_INFO}
  99. AT_INFO = _AT_INFO;
  100. {$EXTERNALSYM AT_INFO}
  101. PAT_INFO = ^AT_INFO;
  102. {$EXTERNALSYM PAT_INFO}
  103. LPAT_INFO = ^AT_INFO;
  104. {$EXTERNALSYM LPAT_INFO}
  105. TAtInfo = AT_INFO;
  106. PAtInfo = PAT_INFO;
  107. _AT_ENUM = record
  108. JobId: DWORD;
  109. JobTime: DWORD_PTR;
  110. DaysOfMonth: DWORD;
  111. DaysOfWeek: UCHAR;
  112. Flags: UCHAR;
  113. Command: LPWSTR;
  114. end;
  115. {$EXTERNALSYM _AT_ENUM}
  116. AT_ENUM = _AT_ENUM;
  117. {$EXTERNALSYM AT_ENUM}
  118. PAT_ENUM = ^AT_ENUM;
  119. {$EXTERNALSYM PAT_ENUM}
  120. LPAT_ENUM = ^AT_ENUM;
  121. {$EXTERNALSYM LPAT_ENUM}
  122. TAtEnum = AT_ENUM;
  123. PAtEnum = PAT_ENUM;
  124. function NetScheduleJobAdd(Servername: LPCWSTR; Buffer: LPBYTE; JobId: LPDWORD): NET_API_STATUS; stdcall;
  125. {$EXTERNALSYM NetScheduleJobAdd}
  126. function NetScheduleJobDel(Servername: LPCWSTR; MinJobId, MaxJobId: DWORD): NET_API_STATUS; stdcall;
  127. {$EXTERNALSYM NetScheduleJobDel}
  128. function NetScheduleJobEnum(Servername: LPCWSTR; var PointerToBuffer: LPBYTE; PrefferedMaximumLength: DWORD; EntriesRead, TotalEntries, ResumeHandle: LPDWORD): NET_API_STATUS; stdcall;
  129. {$EXTERNALSYM NetScheduleJobEnum}
  130. function NetScheduleJobGetInfo(Servername: LPCWSTR; JobId: DWORD; var PointerToBuffer: LPBYTE): NET_API_STATUS; stdcall;
  131. {$EXTERNALSYM NetScheduleJobGetInfo}
  132. implementation
  133. {$IFDEF DYNAMIC_LINK}
  134. var
  135. _NetScheduleJobAdd: Pointer;
  136. function NetScheduleJobAdd;
  137. begin
  138. GetProcedureAddress(_NetScheduleJobAdd, netapi32, 'NetScheduleJobAdd');
  139. asm
  140. MOV ESP, EBP
  141. POP EBP
  142. JMP [_NetScheduleJobAdd]
  143. end;
  144. end;
  145. var
  146. _NetScheduleJobDel: Pointer;
  147. function NetScheduleJobDel;
  148. begin
  149. GetProcedureAddress(_NetScheduleJobDel, netapi32, 'NetScheduleJobDel');
  150. asm
  151. MOV ESP, EBP
  152. POP EBP
  153. JMP [_NetScheduleJobDel]
  154. end;
  155. end;
  156. var
  157. _NetScheduleJobEnum: Pointer;
  158. function NetScheduleJobEnum;
  159. begin
  160. GetProcedureAddress(_NetScheduleJobEnum, netapi32, 'NetScheduleJobEnum');
  161. asm
  162. MOV ESP, EBP
  163. POP EBP
  164. JMP [_NetScheduleJobEnum]
  165. end;
  166. end;
  167. var
  168. _NetScheduleJobGetInfo: Pointer;
  169. function NetScheduleJobGetInfo;
  170. begin
  171. GetProcedureAddress(_NetScheduleJobGetInfo, netapi32, 'NetScheduleJobGetInfo');
  172. asm
  173. MOV ESP, EBP
  174. POP EBP
  175. JMP [_NetScheduleJobGetInfo]
  176. end;
  177. end;
  178. {$ELSE}
  179. function NetScheduleJobAdd; external netapi32 name 'NetScheduleJobAdd';
  180. function NetScheduleJobDel; external netapi32 name 'NetScheduleJobDel';
  181. function NetScheduleJobEnum; external netapi32 name 'NetScheduleJobEnum';
  182. function NetScheduleJobGetInfo; external netapi32 name 'NetScheduleJobGetInfo';
  183. {$ENDIF DYNAMIC_LINK}
  184. end.