Platform SDK: Performance Monitoring

PdhGetRawCounterValue

The PdhGetRawCounterValue function returns the current raw value of the counter.

PDH_STATUS PdhGetRawCounterValue(
  HCOUNTER hCounter,       
  LPDWORD lpdwType,        
  PPDH_RAW_COUNTER pValue  
);

Parameters

hCounter
[in] A handle to the counter from which to retrieve the current raw value.
lpdwType
[out] A pointer to a DWORD that receives the counter type. The possible counter types are described in WINPERF.H. This parameter is optional.
pValue
[out] A pointer to a PDH_RAW_COUNTER structure that receives the counter value.

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 (protected) for the duration of the call to PdhGetRawCounterValue to prevent any changes during processing of the call.

Obtaining the value of rate counters such as Page faults/sec requires that PdhCollectQueryData be called twice, with a specific time interval between the two calls, before calling PdhGetRawCounterValue. Call Sleep to implement the waiting period between the two calls to PdhCollectQueryData.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Header: Declared in Pdh.h.
  Library: Use Pdh.lib.

See Also

PdhGetFormattedCounterValue, PdhCalculateCounterFromRawValue, PdhCollectQueryData