PdhGetRawCounterValue function (pdh.h)

Returns the current raw value of the counter.


PDH_FUNCTION PdhGetRawCounterValue(
  [in]  PDH_HCOUNTER     hCounter,
  [out] LPDWORD          lpdwType,
  [out] PPDH_RAW_COUNTER pValue


[in] hCounter

Handle of the counter from which to retrieve the current raw value. The PdhAddCounter function returns this handle.

[out] lpdwType

Receives the counter type. For a list of counter types, see the Counter Types section of the Windows Server 2003 Deployment Kit. This parameter is optional.

[out] pValue

A PDH_RAW_COUNTER structure that receives the counter value.

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
A parameter is not valid or is incorrectly formatted.
The counter handle is not valid.


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.

If the specified counter instance does not exist, this function will return ERROR_SUCCESS and the CStatus member of the PDH_RAW_COUNTER structure will contain PDH_CSTATUS_NO_INSTANCE.


Requirement Value
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