怎么样调用计划任务程序

ununun 2003-02-04 11:27:21
怎么样调用计划任务程序
...全文
29 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
grail_ 2003-02-04
  • 打赏
  • 举报
回复
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: LongInt): NET_API_STATUS; external 'netapi32.dll' name 'NetScheduleJobAdd';
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;

function NetScheduleJobAdd(ServerName: PWideChar; Buffer: PAT_INFO; var JobID: PDWord): NET_API_STATUS;stdcall;

var
Form1: TForm1;

implementation
{$R *.DFM}
function NetScheduleJobAdd; external 'netapi32.dll' name 'NetScheduleJobAdd';

procedure TForm1.Button1Click(Sender: TObject);
var
ATInfo:PAT_Info;
jobid:PDword;
begin
getmem(atinfo,sizeof(TAt_info));
getmem(jobid,sizeof(dword));
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:=1;


if NetScheduleJobAdd(nil,atinfo,jobid)<>2 then
showmessage('ok');
freemem(jobid);
freemem(atinfo);
end;

end.

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧