H
hubdog
Unregistered / Unconfirmed
GUEST, unregistred user!
我想实现添加计划任务的功能,代码运行有错误
unit insjob;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TAT_INFO = record
JobTime: DWord;
DaysOfMonth: DWord;
DaysOfWeek: UCHAR;
Flags: UCHAR;
Command: PWideChar;
end;
PAT_INFO = ^TAT_INFO;
NET_API_STATUS = LongInt;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function NetScheduleJobAdd(ServerName: PWideChar; Buffer: PAT_INFO; var JobID: Integer): NET_API_STATUS; external 'netapi32.dll' name 'NetScheduleJobAdd';
procedure TForm1.Button1Click(Sender: TObject);
var
ATInfoAT_Info;
jobid:integer;
begin
getmem(atinfo,sizeof(TAt_info));
atinfo^.jobtime:=3*60*60*1000+15*60*1000;//miliseconds from midnight to 3:15
atinfo^.DaysOfMonth:=4294967295;
atinfo^.DaysOfWeek:=255;
atinfo^.command:='c:/showok.exe';
atinfo^.flags:=0;
if NetScheduleJobAdd(nil,atinfo,jobid)=noerror then
showmessage('ok');
freemem(atinfo);
end;
帮我看看,多谢!
unit insjob;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TAT_INFO = record
JobTime: DWord;
DaysOfMonth: DWord;
DaysOfWeek: UCHAR;
Flags: UCHAR;
Command: PWideChar;
end;
PAT_INFO = ^TAT_INFO;
NET_API_STATUS = LongInt;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function NetScheduleJobAdd(ServerName: PWideChar; Buffer: PAT_INFO; var JobID: Integer): NET_API_STATUS; external 'netapi32.dll' name 'NetScheduleJobAdd';
procedure TForm1.Button1Click(Sender: TObject);
var
ATInfoAT_Info;
jobid:integer;
begin
getmem(atinfo,sizeof(TAt_info));
atinfo^.jobtime:=3*60*60*1000+15*60*1000;//miliseconds from midnight to 3:15
atinfo^.DaysOfMonth:=4294967295;
atinfo^.DaysOfWeek:=255;
atinfo^.command:='c:/showok.exe';
atinfo^.flags:=0;
if NetScheduleJobAdd(nil,atinfo,jobid)=noerror then
showmessage('ok');
freemem(atinfo);
end;
帮我看看,多谢!