PdhGetCounterInfo
The PdhGetCounterInfo function retrieves information about a counter, such as data size, counter type, path, and user-supplied data values.
PDH_STATUS PdhGetCounterInfo(
IN HQUERY hCounter, // handle of the counter
IN BOOLEAN bRetrieveExplainText,
// TRUE to retrieve explain text
IN LPDWORD pdwBufferSize, // pointer to size of lpBuffer
IN PPDH_COUNTER_INFO lpBuffer // buffer for counter information
);
Parameters
-
hCounter
-
The handle of the counter from which to retrieve the information.
-
bRetrieveExplainText
-
Determines whether explain text is retrieved. If you set this parameter to TRUE, then the explain text for the counter is retrieved. If you set this parameter to FALSE, the field in the returned buffer is NULL.
-
pdwBufferSize
-
A pointer to the size, in bytes, of the buffer passed in lpBuffer. If the counter requires a buffer larger than is indicated by pdwBufferSize, then PdhGetCounterInfo will return the required buffer size in this field. If the function succeeds, then this field will contain the size of the data returned in lpBuffer. If the size is zero, then no data will be returned in the buffer (in fact, lpBuffer can be NULL); and the size, in bytes, will be returned in the DWORD.
-
lpBuffer
-
A pointer to the data buffer to receive the counter information. The buffer returned is variable-length, because the string data is appended to the end of the fixed-format portion of the structure. This is done so that all data is returned in a single buffer allocated by the caller.
Return Values
If the function succeeds, it returns ERROR_SUCCESS.
If the function fails, the return value is a PDH error status defined in pdhmsg.h. The following are possible error values:
-
PDH_INVALID_ARGUMENT
-
An argument is not correct or is incorrectly formatted.
-
PDH_INVALID_HANDLE
-
The counter handle is not valid.
-
PDH_MORE_DATA
-
The buffer supplied is not large enough to receive the requested data.
See Also
Performance Data Helper Overview, Performance Data Functions, , PDH_COUNTER_INFO