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.

 

In the following examples, the modified object is always saved to disk by a call to IPersistFile::Save. (The IPersistFile interface is a standard COM interface inherited by the task object.)

The following procedure describes how to set a task property.

To set a task property

  1. 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.)
  2. Call ITaskScheduler::Activate to get the ITask interface of the task object. (Note that tasks are currently the only valid type of work item.)
  3. Call the appropriate IScheduledWorkItem method to set the property you are interested in. Note that IScheduledWorkItem methods are inherited by the ITask interface.
  4. 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

 

Task Scheduler 1.0 Examples