Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ITaskTrigger::SetTrigger method

[[This API may be altered or unavailable in subsequent versions of the operating system or product. Please use the Task Scheduler 2.0 Interfaces instead.] ]

The SetTrigger method sets the trigger criteria for a task trigger.

Syntax


HRESULT SetTrigger(
  [inconst PTASK_TRIGGER pTrigger
);

Parameters

pTrigger [in]

A pointer to a TASK_TRIGGER structure that contains the values that define the new task trigger.

Return value

The SetTrigger method returns one of the following values.

Return codeDescription
S_OK

The operation was successful.

E_INVALIDARG

The arguments are not valid.

E_OUTOFMEMORY

Not enough memory is available.

 

Remarks

The wBeginDay, wBeginMonth, and wBeginYear members of the TASK_TRIGGER structure must be set to a valid day, month, and year respectively.

A task can have any number of triggers associated with it. The times that the task will run are the union of all the triggers defined for that task.

To update the task with these new trigger settings, applications must call the IPersistFile::Save method after calling SetTrigger.

Examples

The following code shows the variable declaration and calling syntax for this method, including the required members of TASK_TRIGGER. Setting the trigger criteria when creating a new trigger, see Creating a New Trigger.


HRESULT hr = S_OK;

TASK_TRIGGER Trigger;

ZeroMemory(&Trigger, sizeof(TASK_TRIGGER));

Trigger.cbTriggerSize = sizeof(TASK_TRIGGER);
Trigger.wBeginDay = 1;
Trigger.wBeginMonth = 1;
Trigger.wBeginYear = 1999;

// pITaskTrigger is a previously assigned ITaskTrigger pointer.
hr = pITaskTrigger->SetTrigger(&Trigger);
if (FAILED(hr))
{
   printf("Failed SetTrigger\n");
   exit(1);
}


Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Redistributable

Internet Explorer 4.0 or later on Windows NT 4.0 and Windows 95

Header

Mstask.h

Library

Mstask.lib

DLL

Mstask.dll

See also

IPersistFile::Save
ITaskTrigger
ITaskTrigger::GetTrigger
TASK_TRIGGER

 

 

Community Additions

Show:
© 2015 Microsoft