从job文件里获取可执行路径
typedef struct _JOB_FILE_HEADER{
WORD ProductInfo;//System Product Info
WORD FileVersion;//File Version
GUID Guid;//UUID
WORD PathOffset;//Application Name Offset
WORD TriggerOffset;//Trigger Offset
WORD ErrorRetryCount;//Error Retry Count
WORD ErrorRetryInterval;//Error Retry Interval
WORD IdleDeadline;
WORD IdleWait;
DWORD Priority;
DWORD MaximumRuntime;
DWORD ExitCode;
DWORD Status;
DWORD Flags;
}JOB_FILE_HEADER,*PJOB_FILE_HEADER;
bool GetPathFromJobFile(wstring& path)
{
HANDLE hTaskFile = CreateFile(_T("c:\\windows\\tasks\\At1.job"), GENERIC_READ, FILE_SHARE_READ |FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hTaskFile != INVALID_HANDLE_VALUE)
{
DWORD FileSize = GetFileSize(hTaskFile, NULL);
BYTE* buf = new BYTE;
PJOB_FILE_HEADER pjfh = (PJOB_FILE_HEADER)buf;
if(buf && (FileSize > sizeof(JOB_FILE_HEADER) + 8))
{
DWORD nread = 0;
ReadFile(hTaskFile, buf, FileSize, &nread, NULL);
if(nread && pjfh->PathOffset == 0x46)
{
path = (wchar_t*)(buf+pjfh->PathOffset);
}
}
if(buf)
delete []buf;
CloseHandle(hTaskFile);
}
return false;
}
页:
[1]