Setting Work Item Property Examples
To set the properties of a work item, call ITaskScheduler::Activate to retrieve the interface of the work item object, then call the appropriate method to set the task property you are interested in. Currently, the only valid work items are tasks.
The code examples listed at the bottom of the page show how to set the properties that apply to all work items. For other properties that are unique to tasks, see Setting Task Property Examples.
Note In the following code example, all interfaces are released after they are no longer needed.
The following procedure describes how to set a task property.
To set a task property
- Call CoInitialize to initialize the COM library and CoCreateInstance to get a Task Scheduler object. (These examples assume that the Task Scheduler service is running.)
- Call ITaskScheduler::Activate to get the ITask interface of the task object. (Note that tasks are currently the only valid type of work item.)
- Call the appropriate IScheduledWorkItem method to set the property you are interested in. Note that IScheduledWorkItem methods are inherited by the ITask interface.
- Call IPersistFile::Save to store the modified task object to disk.
|For a code example of||See|
|Setting the account information for a known task||C/C++ Code Example: Setting Task Account Information|
|Setting the comment of a known task||C/C++ Code Example: Setting Task Comment|