使用NetScheduleJobEnum取得AT职位 [英] Get AT jobs with NetScheduleJobEnum

查看:480
本文介绍了使用NetScheduleJobEnum取得AT职位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我想获取所有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);
    }
}

推荐答案

是您过去的问题的变体
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆