问题描述
你好,
我想获取所有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);
}
}
推荐答案
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职位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!