当前位置: 首页>>代码示例>>C++>>正文


C++ ITask::GetFlags方法代码示例

本文整理汇总了C++中ITask::GetFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ ITask::GetFlags方法的具体用法?C++ ITask::GetFlags怎么用?C++ ITask::GetFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITask的用法示例。


在下文中一共展示了ITask::GetFlags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getScheduleTask

/**
 * Get task info from Task scheduler.
 * Returns 0 if task found and no errors, -1 if task not found.
 * If task found: frequency, dayNum, minNum and statusCode are set.
 *
 * @param active  : [OUT] true if task is active
 * @param dayNum  : [OUT] repeating every 'dayNum' days
 * @param minNum  : [OUT] repeating every 'minNum' minutes
 * @return          0 = task found, status correct.
 *                  1 = task found, status incorrect.
 *                  2 = task found but manually changed.
 *                 -1 = task not found.
 *                 -2 = errors occurred.
 */
int getScheduleTask(bool* active, int* dayNum, int* minNum) {

    int ret = 0;
    HRESULT hr = S_OK;
    ITaskScheduler* pITS = NULL;
    ITask*          pITask;
    wstring taskName;

    // Init COM library & create instance for Task scheduler.
    if ((pITS = initScheduleInstance()) == NULL) {
        goto error;
    }

    // Task is associated with current user
    if (getScheduledTaskName(taskName)) {
        goto error;
    }

    //
    // Open the task (fails if task not existing).
    //
    hr = pITS->Activate(taskName.c_str(),
                        IID_ITask,
                        (IUnknown**) &pITask);
    pITS->Release();
    if (FAILED(hr)) {
        goto notExisting;
    }


    //
    // Check task status
    //
    DWORD pdwExitCode;
    hr = pITask->GetExitCode(&pdwExitCode);
    if ((hr & SCHED_S_TASK_HAS_NOT_RUN) || (hr != S_OK)) {
        setErrorF(getLastErrorCode(), DBG_SCHED_LAST_EXECUTION);
        LOG.debug(getLastErrorMsg());
        ret = 1;
    }


    //
    // Check the flags -> active/disabled
    //
    DWORD flag = -1, triggerType = -1;
    pITask->GetFlags(&flag);
    if (flag & TASK_FLAG_DISABLED) {
        *active = false;
    } else {
        *active = true;
    }


    //
    // Get the trigger interface.
    //
    ITaskTrigger *pITaskTrigger;
    hr = pITask->GetTrigger(0, &pITaskTrigger);
    if (FAILED(hr)) {
        char* msg = readSystemErrorMsg(hr);
        setErrorF(getLastErrorCode(), ERR_SCHED_GET_TRIGGER, hr, msg);
        delete [] msg;
        goto error;
    }

    TASK_TRIGGER pTrigger;
    ZeroMemory(&pTrigger, sizeof(TASK_TRIGGER));
    hr = pITaskTrigger->GetTrigger(&pTrigger);
    if (FAILED(hr)) {
        char* msg = readSystemErrorMsg(hr);
        setErrorF(getLastErrorCode(), ERR_SCHED_GET_TRIGGER2, hr, msg);
        delete [] msg;
        goto error;
    }

    //
    // Get values
    //
    int minToSet = pTrigger.MinutesInterval;
    if (minToSet == 1439) {
        minToSet = 1440;    // the value must normalized to get 1 day
    }

    *minNum = minToSet; // pTrigger.MinutesInterval;
    *dayNum = pTrigger.Type.Daily.DaysInterval;
//.........这里部分代码省略.........
开发者ID:PaulCarrick,项目名称:funambol-outlook-client,代码行数:101,代码来源:OutlookScheduler.cpp


注:本文中的ITask::GetFlags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。