ITaskService::GetRunningTasks method (taskschd.h)

Gets a collection of running tasks.

Note  ITaskService::GetRunningTasks will only return a collection of running tasks that are running at or below a user's security context. For example, for members of the Administrators group, GetRunningTasks will return a collection of all running tasks, but for members of the Users group, GetRunningTasks will only return a collection of tasks running under the Users group security context.

 

Syntax

HRESULT GetRunningTasks(
  [in]  LONG                   flags,
  [out] IRunningTaskCollection **ppRunningTasks
);

Parameters

[in] flags

A value from the TASK_ENUM_FLAGS enumeration. Pass in 0 to return a collection of running tasks that are not hidden tasks.

[out] ppRunningTasks

An IRunningTaskCollection interface that contains the currently running tasks.

Pass in a reference to a NULL IRunningTaskCollection interface pointer. Referencing a non-NULL pointer can cause a memory leak because the pointer will be overwritten.

Return value

This method can return one of these values.

Description
E_INVALIDARG
An invalid argument was specified in the method call. Passing a nonzero value to the flags parameter will return E_INVALIDARG.
S_OK
The operation completed successfully.
E_POINTER
NULL was passed into the retVal parameter.
HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED)
The user has not connected to the service.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header taskschd.h
Library Taskschd.lib
DLL Taskschd.dll

See also

IRunningTaskCollection

ITaskService

TASK_ENUM_FLAGS

Task Scheduler