ITaskService::NewTask method (taskschd.h)

Returns an empty task definition object to be filled in with settings and properties and then registered using the ITaskFolder::RegisterTaskDefinition method.

Syntax

HRESULT NewTask(
  [in]  DWORD           flags,
  [out] ITaskDefinition **ppDefinition
);

Parameters

[in] flags

This parameter is reserved for future use and must be set to 0.

[out] ppDefinition

The task definition that specifies all the information required to create a new task.

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

The returned ITaskDefinition pointer must be released after it is used.

Return value

This method can return one of these values.

Return code/value Description
S_OK
0x0
The method returned successfully without error.
E_POINTER
0x80004003
NULL was passed in to the ppDefinition parameter. Pass in a reference to a NULL ITaskDefinition interface pointer.
E_INVALIDARG
0x80070057
A nonzero value was passed into the flags parameter.

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

ITaskService