Szerkesztés

Megosztás a következőn keresztül:


Retrieving Task Property Examples

To retrieve the properties of a task, call ITaskScheduler::Activate to get retrieve the interface of the task object, then call the appropriate ITask method to retrieve the task property that you are interested in. The code examples listed at the bottom of the page show how to retrieve the different task properties.

The code examples listed at the bottom of the page show how to retrieve the properties that are unique to task objects. For other work item properties that also apply to tasks, see Retrieving Work Item Examples.

Note

In the following code example, all interfaces are released after they are no longer needed.

 

Note that if you are retrieving a string property (such as the application name, parameters, or working directory), you must call CoTaskMemFree to free the memory allocated for the returned string.

The following procedure describes how to retrieve a task property.

To retrieve 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 this example gets the "Test Task" task.)
  3. Call the appropriate ITask method to retrieve the property you are interested in.
  4. Process the property as needed. (These examples print the property to the screen.)
  5. If the returned property is a string, call CoTaskMemFree to free the memory allocated for the returned string.
For a code example of See
Retrieving the name of the application associated with a given task C/C++ Code Example: Retrieving the Task Application Name
Retrieving the maximum amount of time the task can run and displaying that number on the screen C/C++ Code Example: Retrieving the Task MaxRunTime
Retrieving the parameter string that is executed when the task is run and displaying that string on the screen C/C++ Code Example: Retrieving Task Parameters
Retrieving the priority level of the task C/C++ Code Example: Retrieving Task Priority
Retrieving the working directory of a task and displaying the path to the working directory on the screen C/C++ Code Example: Retrieving the Task Working Directory

 

Task Scheduler 1.0 Examples