Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[[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.
HRESULT SetTrigger(
[in] const PTASK_TRIGGER pTrigger
);
[in] pTrigger
A pointer to a TASK_TRIGGER structure that contains the values that define the new task trigger.
The SetTrigger method returns one of the following values.
Return code | Description |
---|---|
|
The operation was successful. |
|
The arguments are not valid. |
|
Not enough memory is available. |
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.
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);
}
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | mstask.h |
Library | Mstask.lib |
DLL | Mstask.dll |
Redistributable | Internet Explorer 4.0 or later on Windows NT 4.0 and Windows 95 |
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in