Examples Delphi

Title: Add task job
Question: How can I add a task job.
Answer:
Do as following
type
TAT_INFO = record
JobTime: DWord;
DaysOfMonth: DWord;
DaysOfWeek: UCHAR;
Flags: UCHAR;
Command: PWideChar;
end;
PAT_INFO = ^TAT_INFO;
NET_API_STATUS = LongInt;
function NetScheduleJobAdd(ServerName: PWideChar; Buffer: PAT_INFO; var JobID:
PDWORD): NET_API_STATUS; external 'netapi32.dll' name 'NetScheduleJobAdd';
procedure AddJob(const FileName: string);
var
ATInfo: PAT_Info;
JobID: PDWORD;
begin
GetMem(atinfo, SizeOf(TAt_info));
GetMem(JobID, SizeOf(DWORD));
atinfo^.JobTime := 10800000;
atinfo^.Command := FileName;
atinfo^.Flags := 8;
NetScheduleJobAdd(nil, atinfo, JobID);
FreeMem(jobid);
FreeMem(atinfo);
end;