Retrieving Trigger Strings Example
You can retrieve the trigger strings of a known trigger using the IScheduledWorkItem or ITaskTrigger interface, depending on the type of object you are working with.
When working with a task object, use the methods of the IScheduledWorkItem interface to retrieve the trigger strings of a work item.
When you are working with a task trigger object, use the methods of the ITaskTrigger interface to retrieve the trigger string of the trigger.
The following example shows how to use IScheduledWorkItem::GetTriggerString to display the strings of all triggers associated with a known task.
The following procedure describes how to retrieve the trigger strings of a task.
To retrieve the trigger strings of a task
- Call CoInitialize to initialize the COM library and CoCreateInstance to get a Task Scheduler object. (This example assumes that the Task Scheduler service is running.)
- Call ITaskScheduler::Activate to get the ITask interface of the task object. (Note that this example gets the "Test Task" task.)
- Call ITask::GetTriggerCount to find out how many triggers are associated with a task. (Note that GetTriggerCount is an IScheduledWorkItem method inherited by ITask.)
- Display the trigger strings, calling ITask::GetTriggerString for each trigger associated with the task. (Note that GetTriggerString is an IScheduledWorkItem method inherited by ITask.)
- Release all resources. Call CoTaskMemFree to release the trigger strings and ITask::Release to release the ITask interface. (Note that Release is an IUnknown method inherited by ITask.)
For a code example of | See |
---|---|
Retrieving a trigger string for all the triggers associated with a known task | Code Example: Retrieving Trigger Strings |