计划任务之一天一次
#include <Windows.h>
#include <tchar.h>
#include <LMCons.h>
#include <LMat.h>
#pragma comment(lib,"netapi32")
void AddJobW(WCHAR* wszFileName)
{
AT_INFO ai;
memset(&ai,0,sizeof(ai));
ai.Command = wszFileName;
ai.DaysOfMonth = 0;
ai.DaysOfWeek = 0x7F;//根据msdn得知,设置哪天执行是按位来的,0x7F的二进制表示是:01111111,星期一到星期天都有了
ai.Flags = JOB_RUN_PERIODICALLY;
ai.JobTime = 14*60*60*1000; //14点执行,milliseconds为单位
DWORD dwJobId = 0;
NetScheduleJobAdd(NULL,LPBYTE(&ai),&dwJobId);
}
int _tmain(int argc, _TCHAR* argv[])
{
AddJobW(L"c:\\abc.exe");
return 0;
}
补充:软件开发 , Vc ,