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


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

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


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

示例1: SaveTask


//.........这里部分代码省略.........
  //SecureZeroMemory(pszPwd, sizeof(pszPwd));
  


    // Set the flags on the task object
    
    // The two flags below are the default for events created via the task 
    // scheduler UI.
    // Note that I _don't_ set TASK_FLAG_DELETE_WHEN_DONE.  Setting this flag
    // is bad if you have the "Notify me of missed tasks" option on in the
    // scheduler.  If this flag is set and the event is missed, the scheduler
    // nukes the event without notifying you .  How mean.

    dwTaskFlags = TASK_FLAG_RUN_ONLY_IF_LOGGED_ON;

    // On NT, set the interactive flag so the user can see it.
    if ( !( GetVersion() & 0x80000000 ) )
        {
        dwTaskFlags |= TASK_FLAG_INTERACTIVE;
        }

    hr = pITask->SetFlags ( dwTaskFlags );

    if ( FAILED (hr) )
        {
        TRACE1("CScheduledTask::SaveTask() - failed to set task flags. Return = 0x%08X\n",
               (DWORD) hr );
        return hr;
        }


    // Now, create a trigger to run the task at our specified time.

    hr = pITask->CreateTrigger ( &wTrigNumber, &pITaskTrig );

    if ( FAILED (hr) )
        {
        TRACE1("CScheduledTask::SaveTask() - failed to create a task trigger. Return = 0x%08X\n",
               (DWORD) hr );
        return hr;
        }


    // Now, fill in the trigger as necessary.  Note that the seconds field of
    // m_timeStart is not used since the scheduler only stores the hour
    // and minute of the starting time.

    ZeroMemory ( &rTrigger, sizeof (TASK_TRIGGER) );

    rTrigger.cbTriggerSize = sizeof (TASK_TRIGGER);
    rTrigger.wBeginYear    = m_timeStart.wYear;
    rTrigger.wBeginMonth   = m_timeStart.wMonth;
    rTrigger.wBeginDay     = m_timeStart.wDay;
    rTrigger.wStartHour    = m_timeStart.wHour;
    rTrigger.wStartMinute  = m_timeStart.wMinute;

    if ( 0 != m_timeEnd.wYear )
        {
        rTrigger.rgFlags   = TASK_TRIGGER_FLAG_HAS_END_DATE;
        rTrigger.wEndYear  = m_timeEnd.wYear;
        rTrigger.wEndMonth = m_timeEnd.wMonth;
        rTrigger.wEndDay   = m_timeEnd.wDay;
        }


    switch ( m_eFreq )
开发者ID:DjPasco,项目名称:Mag,代码行数:67,代码来源:ScheduledTask.cpp

示例2: setScheduleTask


//.........这里部分代码省略.........
            pITask->SetComment(SCHED_COMMENT);
        }
        else {
            char* msg = readSystemErrorMsg(hr);
            setErrorF(getLastErrorCode(), ERR_SCHED_ACTIVATE, hr, msg);
            delete [] msg;
            pITS->Release();
            goto error;
        }
    }
    pITS->Release();


    //
    // Set task params: flags, account info, parameters
    if (strcmp(NEVER, frequency) == 0) {
        pITask->SetFlags(TASK_FLAG_DISABLED);
    } 
    else {
        pITask->SetAccountInformation(user.c_str(), NULL);
        pITask->SetFlags(TASK_FLAG_INTERACTIVE | TASK_FLAG_RUN_ONLY_IF_LOGGED_ON);
    }

    // ...so we have "OutlookPlugin.exe schedule"    
    pITask->SetParameters(SCHED_PARAM);


    //
    // Get/create the trigger object.
    //
    ITaskTrigger *pITaskTrigger;
    if (newTask) {
        WORD piNewTrigger;
        hr = pITask->CreateTrigger(&piNewTrigger, &pITaskTrigger);
        if (FAILED(hr)) {
            char* msg = readSystemErrorMsg(hr);
            setErrorF(getLastErrorCode(), ERR_SCHED_CREATE_TRIGGER, hr, msg);
            delete [] msg;
            goto error;
        }
    }
    else {
        hr = pITask->GetTrigger(0, &pITaskTrigger);
        if (FAILED(hr)) {
            char* msg = readSystemErrorMsg(hr);
            setErrorF(getLastErrorCode(), ERR_SCHED_GET_TRIGGER, hr, msg);
            delete [] msg;
            goto error;
        }
    }

    //////////////////////////////////////////////////////
    // Define TASK_TRIGGER structure.
    // Start time is derived from NOW.
    //////////////////////////////////////////////////////
    TASK_TRIGGER pTrigger;
    ZeroMemory(&pTrigger, sizeof (TASK_TRIGGER));

    time_t timer;
    time(&timer);
    struct tm* now = localtime(&timer);

    int minToSet = minNum;
    if (minToSet == 1440) {
        minToSet = 1439;   // this because the windows scheduler thrown an error if
                            // the value is a day
开发者ID:PaulCarrick,项目名称:funambol-outlook-client,代码行数:67,代码来源:OutlookScheduler.cpp

示例3: SaveTask


//.........这里部分代码省略.........
        hr = pITask->SetComment ( T2COLE( (LPCTSTR) m_sComment ));

        if ( FAILED (hr) )
            {
            TRACE1("CTask::SaveTask() - failed to set task comment. Return = 0x%08X\n",
                   (DWORD) hr );
            return hr;
            }
        }


    // ustawiamy flagi
    //zapraszam do eksperymentow z flaga TASK_FLAG_DELETE_WHEN_DONE...
    dwTaskFlags = TASK_FLAG_DONT_START_IF_ON_BATTERIES |
                  TASK_FLAG_KILL_IF_GOING_ON_BATTERIES;

    // na NT ustawimy flage interactive
    if ( !( GetVersion() & 0x80000000 ) )
        {
        dwTaskFlags |= TASK_FLAG_INTERACTIVE;
        }

    hr = pITask->SetFlags ( dwTaskFlags );

    if ( FAILED (hr) )
        {
        TRACE1("CTask::SaveTask() - failed to set task flags. Return = 0x%08X\n",
               (DWORD) hr );
        return hr;
        }


    // teraz tworzymy Trigger, czyli wyzwalacz
    hr = pITask->CreateTrigger ( &wTrigNumber, &pITaskTrig );

    if ( FAILED (hr) )
        {
        TRACE1("CTask::SaveTask() - failed to create a task trigger. Return = 0x%08X\n",
               (DWORD) hr );
        return hr;
        }


    //ustawimy parametry triggera
	//zwroc uwage ze sekundy sa ignorowane
    ZeroMemory ( &rTrigger, sizeof (TASK_TRIGGER) );

    rTrigger.cbTriggerSize = sizeof (TASK_TRIGGER);
    rTrigger.wBeginYear    = m_timeStart.wYear;
    rTrigger.wBeginMonth   = m_timeStart.wMonth;
    rTrigger.wBeginDay     = m_timeStart.wDay;
    rTrigger.wStartHour    = m_timeStart.wHour;
    rTrigger.wStartMinute  = m_timeStart.wMinute;

    if ( 0 != m_timeEnd.wYear )
        {
        rTrigger.rgFlags   = TASK_TRIGGER_FLAG_HAS_END_DATE;
        rTrigger.wEndYear  = m_timeEnd.wYear;
        rTrigger.wEndMonth = m_timeEnd.wMonth;
        rTrigger.wEndDay   = m_timeEnd.wDay;
        }


    switch ( m_eFreq )
        {
        case freqOnce: 
开发者ID:tuku1185,项目名称:taskscheduler,代码行数:67,代码来源:CTask.cpp


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