PdhParseCounterPathA function (pdh.h)

Parses the elements of the counter path and stores the results in the PDH_COUNTER_PATH_ELEMENTS structure.

Syntax

PDH_FUNCTION PdhParseCounterPathA(
  [in]      LPCSTR                       szFullPathBuffer,
  [out]     PPDH_COUNTER_PATH_ELEMENTS_A pCounterPathElements,
  [in, out] LPDWORD                      pdwBufferSize,
            DWORD                        dwFlags
);

Parameters

[in] szFullPathBuffer

Null-terminated string that contains the counter path to parse. The maximum length of a counter path is PDH_MAX_COUNTER_PATH.

[out] pCounterPathElements

Caller-allocated buffer that receives a PDH_COUNTER_PATH_ELEMENTS structure. The structure contains pointers to the individual string elements of the path referenced by the szFullPathBuffer parameter. The function appends the strings to the end of the PDH_COUNTER_PATH_ELEMENTS structure. The allocated buffer should be large enough for the structure and the strings. Set to NULL if pdwBufferSize is zero.

[in, out] pdwBufferSize

Size of the pCounterPathElements buffer, in bytes. If zero on input, the function returns PDH_MORE_DATA and sets this parameter to the required buffer size. If the buffer is larger than the required size, the function sets this parameter to the actual size of the buffer that was used. If the specified size on input is greater than zero but less than the required size, you should not rely on the returned size to reallocate the buffer.

dwFlags

Reserved. Must be zero.

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
A parameter is not valid.
PDH_MORE_DATA
The pCounterPathElements buffer is too small to contain the path elements. This return value is expected if pdwBufferSize is zero on input. If the specified size on input is greater than zero but less than the required size, you should not rely on the returned size to reallocate the buffer.
PDH_INVALID_PATH
The path is not formatted correctly and cannot be parsed. For example, on some releases you could receive this error if the specified size on input is greater than zero but less than the required size.
PDH_MEMORY_ALLOCATION_FAILURE
Unable to allocate memory in order to complete the function.

Remarks

You should call this function twice, the first time to get the required buffer size (set pCounterPathElements to NULL and pdwBufferSize to 0), and the second time to get the data.

Note

The pdh.h header defines PdhParseCounterPath as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

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

PDH_COUNTER_PATH_ELEMENTS

PdhMakeCounterPath