使用NetScheduleJobEnum取得AT职位 [英] Get AT jobs with NetScheduleJobEnum
问题描述
你好,
我想获取所有AT计划任务的应用程序名称的列表.
我正在使用NetScheduleJobEnum()和一个AT_ENUM结构数组.但是在我的代码中,运行NetScheduleJobEnum后,buffPtr并不指向AT_ENUM,并且该行:
for(ai = buffPtr, cnt = 0; cnt < nrRead; cnt++, ++buffPtr)
甚至没有运行一次.我正在附上我的代码.
问题是什么?
谢谢
Hello,
I want to get a list of all the AT scheduled tasks'' application names.
I''m using NetScheduleJobEnum() and an array of AT_ENUM structs. But in my code, after running of NetScheduleJobEnum, buffPtr doesn''t point to an AT_ENUM, and the line:
for(ai = buffPtr, cnt = 0; cnt < nrRead; cnt++, ++buffPtr)
doesn''t run even one time. I''m attaching my code.
What is the problem?
Thanks
DWORD res;
DWORD id;
DWORD maxid;
AT_ENUM* buffPtr = NULL;
AT_ENUM* ai;
DWORD nrRead;
DWORD posRead;
DWORD resumHandle;
DWORD cnt;
CString str;
ITaskScheduler *pITS;
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_CTaskScheduler,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITaskScheduler,
(void **) &pITS);
res = ::NetScheduleJobEnum(NULL,
(LPBYTE*)&buffPtr,
MAX_PREFERRED_LENGTH,
&nrRead,
&posRead,
&resumHandle);
if(res != 0)
{
int i;
}
else
for(ai = buffPtr, cnt = 0; cnt < nrRead; cnt++, ++buffPtr)
{
str.Format("Jobid: %d Command: %s", ai->JobId, ai->Command);
::AfxMessageBox(str);
}
if(buffPtr != NULL)
{
NetApiBufferFree(buffPtr);
}
}
推荐答案
是您过去的问题的变体 ^ ]?
请参阅我的答案.希望对您有所帮助.
这可能是Task Scheduler版本之间的兼容性问题.您计划的任务可能对此代码不可见.任务以不同的方式存储,具体取决于您用于计划任务的实用程序或API.我建议您对我过去的答案中引用的两个版本的Task Scheduler API使用代码示例.
-SA
Is it a variant of your past Question get application names of AT jobs from scheduled tasks[^]?
Please see my Answer. I hope it will be helpful here as well.
It can be the problem of compatibility between versions of Task Scheduler. You scheduled tasks could be invisible to this code. The tasks are stored in different ways, depending on what utility or API you have used to schedule them. I suggest you use code samples for both versions of Task Scheduler API referenced in my past Answer.
—SA
res = ::NetScheduleJobEnum(NULL,
(LPBYTE*)&buffPtr,
MAX_PREFERRED_LENGTH,
&nrRead,
&posRead,
NULL);
if(res != 0)
{
int i;
}
else
for(ai = buffPtr, cnt = 0; cnt < nrRead; cnt++, ++buffPtr)
{
str.Format(L"Jobid: %d Command: %s", ai->JobId, ai->Command);
::AfxMessageBox(str);
}
if(buffPtr != NULL)
{
NetApiBufferFree(buffPtr);
}
ULL)
{
NetApiBufferFree(buffPtr);
}
ULL)
{
NetApiBufferFree(buffPtr);
}
ULL)
{
NetApiBufferFree(buffPtr);
}
ULL)
{
NetApiBufferFree(buffPtr);
}
这篇关于使用NetScheduleJobEnum取得AT职位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!