FormatFromRawValue

The FormatFromRawValue function converts one raw performance data value to the specified format, or two raw performance data values if the format conversion is time-based.

public static unsafe extern int FormatFromRawValue(
          uint dwCounterType,
          uint dwFormat,
          ref long pTimeBase,
          NativeMethods.PDH_RAW_COUNTER pRawValue1,
          NativeMethods.PDH_RAW_COUNTER pRawValue2,
          NativeMethods.PDH_FMT_COUNTERVALUE pFmtValue
        );

Parameters

Parameter Description

dwCounterType

[in] Type of counter. This parameter can be one of the counter types defined in Winperf.h, except for PERF_LARGE_RAW_FRACTION and PERF_LARGE_RAW_BASE. Refer to the counter list contained in the Counters.chm file provided with the Windows 2000 Resource Kit for a description of the counter type defined in Winperf.h. The Counters.chm file is located in the ResourceKit folder when the Resource Kit is installed.

dwFormat

[in] Format to which the raw performance data is to be converted. This parameter can be one 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.

pTimeBase

[in] Pointer to the time base, if necessary for the format conversion. If time base information is not necessary for the format conversion, the value of this parameter is ignored.

pRawValue1

[in] Pointer to a PDH_RAW_COUNTER structure that represents a raw performance value.

pRawValue2

[in] Pointer to a PDH_RAW_COUNTER structure that represents a second raw performance value, if necessary for the format conversion. If a second raw performance value is not necessary, this parameter should be NULL.

pFmtValue

[out] Pointer to a PDH_FMT_COUNTERVALUE structure that receives the formatted performance value.

Property 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

PDH_INVALID_ARGUMENT

An argument is not correct or is incorrectly formatted.

PDH_INVALID_HANDLE

The counter handle is not valid.

Requirements

Header: pdh.h