IEnumWorkItems::Next method (mstask.h)

[[This API may be altered or unavailable in subsequent versions of the operating system or product. Please use the Task Scheduler 2.0 Interfaces instead.] ]

Retrieves the next specified number of tasks in the enumeration sequence.

If there are fewer than the requested number of tasks left in the sequence, all the remaining elements are retrieved.

Syntax

HRESULT Next(
  [in]  ULONG  celt,
  [out] LPWSTR **rgpwszNames,
  [out] ULONG  *pceltFetched
);

Parameters

[in] celt

The number of tasks to retrieve.

[out] rgpwszNames

A pointer to an array of pointers (LPWSTR) to null-terminated character strings containing the file names of the tasks returned from the enumeration sequence. These file names are taken from the Scheduled Tasks folder and have the ".job" extension.

After processing the names returned in rgpwszNames, you must first free each character string in the array and then the array itself using CoTaskMemFree.

[out] pceltFetched

A pointer to the number of tasks returned in rgpwszNames. If the celt parameter is 1, this parameter may be NULL.

Return value

Returns one of the following values.

Return code Description
S_OK
The number of tasks retrieved equals the number requested.
S_FALSE
The number returned is less than the number requested. (Thus, there are no more tasks to enumerate.)
E_INVALIDARG
A parameter is invalid.
E_OUTOFMEMORY
Not enough memory is available.

Remarks

The IEnumWorkItems interface also provides methods for resetting the enumeration, skipping tasks, and making a copy of the current state of the enumeration.

Examples

For an example of how to use Next to enumerate the tasks in the Scheduled Tasks folder, see Enumerating Tasks Example.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header mstask.h
Library Mstask.lib
DLL Mstask.dll
Redistributable Internet Explorer 4.0 or later on Windows NT 4.0 and Windows 95

See also

IEnumWorkItems

IEnumWorkItems::Clone

IEnumWorkItems::Reset

IEnumWorkItems::Skip