unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br><br>type<br> Pat_info= ^at_info;<br> at_info = record<br> JobTime
WORD;<br> DaysOfMonth
WORD;<br> DaysOfWeek:UCHAR;<br> Flags:UCHAR;<br> Command:LPWSTR;<br> end;<br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br>const<br> JOB_RUN_PERIODICALLY = $01; { in-/output flag }<br> JOB_EXEC_ERROR = $02; { output flag }<br> JOB_RUNS_TODAY = $04; { output flag }<br> JOB_ADD_CURRENT_DATE = $08; { input flag }<br> JOB_NONINTERACTIVE = $10; { in-/output flag }<br><br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>function NetScheduleJobAdd(<br> aMachine:string; // empty string for local machine<br> aTime: DWORD; // millisec. from midnight<br> DaysOfMonth: DWORD; //bit 0: 1. day bit1: 2. day value=0: not assigned<br> DaysOfWeek: byte; //bit 0: Monday .... value=0: not assigned<br> Flags: byte; //<br>//JOB_RUN_PERIODICALLY<br>//If this flag bit is set, the job runs on every day for which corresponding<br>///bits in DaysOfMonth or DaysOfWeek are set. If this flag bit is clear, then<br>//job runs only once for each bit that was set in DaysOfMonth or DaysOfWeek at<br>//the time of job submission.<br>//JOB_ADD_CURRENT_DATE<br>//When this flag bit is set, the job will also execute at the first<br>//occurrence of JobTime at the computer to which the job is submitted. In<br>//other words, setting this flag bit is equivalent to setting the<br>//corresponding day bit in the DaysOfMonth bitmask.<br> mycommand: Widestring )
WORD;<br>// Result: Win32Error<br>var hLib : THandle;<br> Flag : DWord;<br> Ergebnis : DWord;<br> P : function (Servername:LPCWSTR;Buffer
at_info;JobId:LPDWORD ): DWord;<br>stdcall; // NetScheduleJobAdd<br> myatinfo: at_info;<br> pmyatinfo: pat_info;<br>begin<br> P := nil;<br> hLib := LoadLibrary('NETAPI32.DLL');<br> P := GetProcAddress(hLib,'NetScheduleJobAdd');<br><br> myatinfo.JobTime:=aTime;<br> myatinfo.DaysOfMonth:=DaysOfMonth;<br> myatinfo.DaysOfWeek:=DaysOfWeek;<br> myatinfo.Flags:=Flags;<br> myatinfo.Command:=PWideChar(mycommand);<br><br> pmyatinfo:=@myatinfo;<br> Result := P(PWideChar(aMachine),pmyatinfo,@flag);<br><br> FreeLibrary(hLib);<br>end;<br><br><br><br>{function NetScheduleJobGetInfo(<br> aMachine:string; // empty string for local machine<br> JobID : dword;<br> Myflg : byte) : dword; //<br>//JOB_RUN_PERIODICALLY<br>//If this flag bit is set, the job runs on every day for which corresponding<br>///bits in DaysOfMonth or DaysOfWeek are set. If this flag bit is clear, then<br>//job runs only once for each bit that was set in DaysOfMonth or DaysOfWeek at<br>//the time of job submission.<br>//JOB_ADD_CURRENT_DATE<br>//When this flag bit is set, the job will also execute at the first<br>//occurrence of JobTime at the computer to which the job is submitted. In<br>//other words, setting this flag bit is equivalent to setting the<br>//corresponding day bit in the DaysOfMonth bitmask.<br>// Result: Win32Error<br>var hLib : THandle;<br> Flag : DWord;<br> Ergebnis : DWord;<br> P : procedure (Servername:LPCWSTR;JobId
WORD;Buffer
at_info);<br>stdcall; // NetScheduleJobAdd<br> myatinfo: Pat_info;<br> pmyatinfo: pat_info;<br>begin<br> P := nil;<br> hLib := LoadLibrary('NETAPI32.DLL');<br> P := GetProcAddress(hLib,'NetScheduleJobGetInfo');<br><br> myatinfo.Flags:=MyFlg;<br><br> pmyatinfo:=@myatinfo;<br> Result := P(PWideChar(aMachine),JOBID,myatinfo);<br><br> FreeLibrary(hLib);<br>end;}<br><br><br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>NetScheduleJobAdd('',54000000,0,0,1, 'c:/project1.exe');<br>//showmessage((NetScheduleJobGetInfo('',1,JOB_RUN_PERIODICALLY)));<br><br>end;<br><br>end.