Enumerating Tasks Example
To enumerate tasks, you must call ITaskScheduler::Enum to create an enumeration object. Then, use the enumeration object's IEnumWorkItems interface to enumerate the tasks in the Scheduled Tasks folder.
The following procedure describes how to enumerate the tasks in the Scheduled Tasks folder.
To enumerate the tasks in the Scheduled Tasks folder
- 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::Enum to get an enumeration object.
- Call IEnumWorkItems::Next to retrieve the tasks. (This example tries to retrieve five tasks with each call.)
- Process the tasks returned. (This example simply prints the name of each task to the screen.
- Release resources. Call CoTaskMemFree to free the memory used for names.
For a code example of | See |
---|---|
Enumerating all the tasks in the Scheduled Tasks folder of the local computer | C/C++ Code Example: Enumerating Tasks |
Related topics