Platform SDK: Performance Monitoring

PdhGetFormattedCounterArray

The PdhGetFormattedCounterArray function returns an array of values of the specified counter in the format requested by the caller.

PDH_STATUS PdhGetFormattedCounterArray(
  HCOUNTER hCounter,            
  DWORD dwFormat,               
  LPDWORD lpdwBufferSize,       
  LPDWORD lpdwBufferCount,      
  PPDH_FMT_COUNTERVALUE_ITEM ItemBuffer 
);

Parameters

hCounter
[in] A handle to the counter whose current value is to be formatted and returned.
dwFormat
[in] The formatting information sent by the caller to indicate how the data should be returned. This parameter can be one of the following values.
Value Meaning
PDH_FMT_DOUBLE Return data as a double-precision floating point real.
PDH_FMT_LARGE Return data as a 64-bit integer.
PDH_FMT_LONG Return data as a long integer.

The value selected from the previous table can optionally be combined using the OR operator with one of the following scaling flags.
Value Meaning
PDH_FMT_NOSCALE Do not apply the default scaling factor.
PDH_FMT_NOCAP100 Counter values above 100 (for example, counter values measuring the processor load on multiprocessor machines) will not be reset to 100. The default behavior is that counter values are capped at a value of 100.
PDH_FMT_1000 Multiply the actual value by 1000.

lpdwBufferSize
[in/out] A pointer to a DWORD that contains the size, in bytes, of the buffer pointed to by ItemBuffer.
lpdwBufferCount
[out] A pointer to a DWORD that contains the number of counter values in the buffer pointed to by ItemBuffer.
ItemBuffer
[out] A pointer to an array of PDH_FMT_COUNTERVALUE_ITEM structures that receives the counter values.

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.

Error value Description
PDH_INVALID_ARGUMENT An argument is not correct or is incorrectly formatted.
PDH_INVALID_HANDLE The counter handle is not valid.

Remarks

The data for the counter is locked for the duration of the call to PdhGetFormattedCounterArray to prevent any changes during the processing of the call.

The value of hCounter can be obtained by a call to PdhAddCounter, with a wildcard specified for the instance name.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Header: Declared in Pdh.h.
  Library: Use Pdh.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows 2000.

See Also

PdhGetFormattedCounterValue, PdhGetRawCounterValue, PdhGetRawCounterArray, PDH_FMT_COUNTERVALUE_ITEM, PdhAddCounter