티스토리 뷰
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
Pat_info = ^at_info;
at_info = record
JobTime: DWORD;
DaysOfMonth: DWORD;
DaysOfWeek: UCHAR;
Flags: UCHAR;
Command: LPWSTR;
end;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
JOB_RUN_PERIODICALLY = $01; { in-/output flag }
JOB_EXEC_ERROR = $02; { output flag }
JOB_RUNS_TODAY = $04; { output flag }
JOB_ADD_CURRENT_DATE = $08; { input flag }
JOB_NONINTERACTIVE = $10; { in-/output flag }
var
Form1: TForm1;
implementation
{$R *.DFM}
function NetScheduleJobAdd(
aMachine: string; // empty string for local machine
aTime: DWORD; // millisec. from midnight
DaysOfMonth: DWORD; //bit 0: 1. day bit1: 2. day value=0: not assigned
DaysOfWeek: byte; //bit 0: Monday .... value=0: not assigned
Flags: byte; //
mycommand: Widestring): DWORD;
var hLib: THandle;
Flag: DWord;
Ergebnis: DWord;
P: function(Servername: LPCWSTR; Buffer: Pat_info; JobId: LPDWORD): DWord;
stdcall; // NetScheduleJobAdd
myatinfo: at_info;
pmyatinfo: pat_info;
begin
P := nil;
hLib := LoadLibrary('NETAPI32.DLL');
P := GetProcAddress(hLib, 'NetScheduleJobAdd');
myatinfo.JobTime := aTime;
myatinfo.DaysOfMonth := DaysOfMonth;
myatinfo.DaysOfWeek := DaysOfWeek;
myatinfo.Flags := Flags;
myatinfo.Command := PWideChar(mycommand);
pmyatinfo := @myatinfo;
Result := P(PWideChar(aMachine), pmyatinfo, @flag);
FreeLibrary(hLib);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
D: TDateTime;
aTime: DWORD;
begin
//시 분
aTime := (14 * 3600 + 52 * 60) * 1000;
NetScheduleJobAdd('', aTime, 0, 0, 1, 'calc.exe');
end;
end.
'프로그래밍 > Delphi' 카테고리의 다른 글
[델파이소스] 윈도우 핸들로 실행화일명 찾기 (0) | 2009.08.05 |
---|---|
[델파이소스] IDFTP 이용한 디렉토리 통째 업로드 (0) | 2009.08.05 |
[델파이소스] 문자열이 올바른 IP 인지 확인 함수 (0) | 2009.08.05 |
[델파이소스] 폼이 화면 밖으로 나가지 못하게 (0) | 2009.08.05 |
[델파이소스] PC재부팅, PC끄기, 로그오프 (0) | 2009.08.05 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크