本文整理汇总了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 )
示例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
示例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: