PdhCalculateCounterFromRawValue

The PdhCalculateCounterFromRawValue function computes the current value of a counter as referenced by the hCounter parameter, using the raw counter data passed in the parameter list.

PDH_STATUS PdhCalculateCounterFromRawValue(
  IN HCOUNTER hCounter,           // handle of the counter
  IN DWORD dwFormat,              // format code
  IN PPDH_RAW_COUNTER rawValue1,  // first raw counter
  IN PPDH_RAW_COUNTER rawValue2,  // second raw counter
  IN PPDH_FMT_COUNTERVALUE fmtValue  // calculated value
);
 

Parameters

hCounter
The handle of the counter used for the computation. This determines how the data will be computed.
dwFormat
The format code composed of the following values:
Value Meaning
PDH_FMT_DOUBLE Return the calculated value as a double-precision floating point real.
PDH_FMT_LARGE Return the calculated value as a 64-bit integer.
PDH_FMT_LONG Return the calculated value as a long integer.

The value selected from the previous table can be combined using the OR operator with one of the following scaling flags:

Flag Meaning
PDH_FMT_NOSCALE Do not apply the counter's scaling factors in the calculation.
PDH_FMT_1000 Multiply the final value by 1000.

rawValue1
A pointer to the raw counter value used to compute the counter value. Some counters (for example, rate counters) require two raw values for a calculation. The format of the buffer depends on the type of counter to be processed.
rawValue2
A pointer to the raw counter value used in computations for counters that require two raw values (for example, rate counters). This value must be the older of the two raw values.
fmtValue
A pointer to the data buffer that will receive the calculated 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:

Value Meaning
PDH_INVALID_ARGUMENT An argument is not correct or is incorrectly formatted.
PDH_INVALID_HANDLE The counter handle is not valid.

See Also

Performance Data Helper Overview, Performance Data Functions, , PdhGetFormattedCounterValue, PdhGetRawCounterValue, PdhSetCounterScaleFactor