タスクスケジューラーをいじくる

非公開APIを使用してタスクスケジューラーをいじくります。
ここでは主に以下のことを行います。
 ・タスクスケジューラーの有効化
 ・タスクスケジューラーの一時停止
 ・タスクスケジューラーの終了
 ・タスクスケジューラーの起動(標準のAPIで起動)
※Windows98で動作確認(それ以外のOSでは使用できないかも知れません(^^;)



■使用するAPI関数

■ソースは下記のようになります。

■非公開APIの定義
function System_Agent_Enable(dwFlag : integer):integer;stdcall;
external 'sage.dll';

procedure System_Agent_Terminate;stdcall;
external 'sage.dll';

■タスクスケジューラーいじくる
//タスクスケジューラーの有効化
procedure TForm1.Button1Click(Sender: TObject);
begin
 System_Agent_Enable(1);
end;

//タスクスケジューラーの一時停止
procedure TForm1.Button2Click(Sender: TObject);
begin
 System_Agent_Enable(2);
end;

//タスクスケジューラーの起動
procedure TForm1.Button3Click(Sender: TObject);
begin
 Winexec('Sage.exe',SW_SHOW);
end;

//タスクスケジューラーの終了
procedure TForm1.Button4Click(Sender: TObject);
begin
 System_Agent_Terminate
end;







Win32 APIのページへ



ホーム PV ランキング