PdhEnumObjectsHA function

Returns a list of objects available on the specified computer or in the specified log file.

This function is identical to PdhEnumObjects, except that it supports the use of handles to data sources.

Syntax

PDH_FUNCTION PdhEnumObjectsHA(
  PDH_HLOG hDataSource,
  LPCSTR   szMachineName,
  PZZSTR   mszObjectList,
  LPDWORD  pcchBufferSize,
  DWORD    dwDetailLevel,
  BOOL     bRefresh
);

Parameters

hDataSource

Handle to a data source returned by the PdhBindInputDataSource function.

szMachineName

Null-terminated string that specifies the name of the computer used to enumerate the performance objects.

Include the leading slashes in the computer name, for example, \computername.

If szDataSource is NULL, you can set szMachineName to NULL to specify the local computer.

mszObjectList

Caller-allocated buffer that receives the list of object names. Each object name in this list is terminated by a null character. The list is terminated with two null-terminator characters. Set to NULL if pcchBufferLength is zero.

pcchBufferSize

Size of the mszObjectList buffer, in TCHARs. If zero on input, the function returns PDH_MORE_DATA and sets this parameter to the required buffer size. If the buffer is larger than the required size, the function sets this parameter to the actual size of the buffer that was used. If the specified size on input is greater than zero but less than the required size, you should not rely on the returned size to reallocate the buffer.

Windows XP:  Add one to the required buffer size.

dwDetailLevel

Detail level of the performance items to return. All items that are of the specified detail level or less will be returned (the levels are listed in increasing order). This parameter can be one of the following values.

Value Meaning
PERF_DETAIL_NOVICE
Novice user level of detail.
PERF_DETAIL_ADVANCED
Advanced user level of detail.
PERF_DETAIL_EXPERT
Expert user level of detail.
PERF_DETAIL_WIZARD
System designer level of detail.

bRefresh

Indicates if the cached object list should be automatically refreshed. Specify one of the following values.

If you call this function twice, once to get the size of the list and a second time to get the actual list, set this parameter to TRUE on the first call and FALSE on the second call. If both calls are TRUE, the second call may also return PDH_MORE_DATA because the object data may have changed between calls.

Value Meaning
TRUE
The object cache is automatically refreshed before the objects are returned.
FALSE
Do not automatically refresh the cache.

Return value

If the function succeeds, it returns ERROR_SUCCESS.

If the function fails, the return value is a system error code or a PDH error code. The following are possible values.

Return code Description
PDH_MORE_DATA
The mszObjectList buffer is too small to hold the list of objects. This return value is expected if pcchBufferLength is zero on input. If the specified size on input is greater than zero but less than the required size, you should not rely on the returned size to reallocate the buffer.
PDH_CSTATUS_NO_MACHINE
The specified computer is offline or unavailable.
PDH_CSTATUS_NO_OBJECT
The specified object could not be found.
PDH_INVALID_ARGUMENT
A parameter is not valid. For example, on some releases you could receive this error if the specified size on input is greater than zero but less than the required size.

Remarks

You should call this function twice, the first time to get the required buffer size (set mszObjectList to NULL and pcchBufferLength to 0), and the second time to get the data.

Requirements

   
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header pdh.h
Library Pdh.lib
DLL Pdh.dll

See also

PdhBindInputDataSource

PdhEnumObjectItemsH