Platform SDK: Performance Monitoring

PdhParseCounterPath

The PdhParseCounterPath function parses the elements of the counter path and stores the results in the structure passed by the caller.

PDH_STATUS PdhParseCounterPath(
  LPCTSTR szFullPathBuffer,  
  PDH_COUNTER_PATH_ELEMENTS *pCounterPathElements,
  LPDWORD pdwBufferSize,  
  DWORD dwFlags  
);

Parameters

szFullPathBuffer
[in] A pointer to a null-terminated string containing the name of the buffer that contains the counter path to parse.
pCounterPathElements
[out] A pointer to a PDH_COUNTER_PATH_ELEMENTS structure that receives the individual components of the path referenced by the szFullPathBuffer parameter. The buffer space allocated for this should be large enough for the structure and the strings that will be referenced by the members in this structure. As this function parses the elements in the path, they are stored in the buffer after the PDH_COUNTER_PATH_ELEMENTS structure. This allows the calling function to allocate, and eventually free, only a single block of memory for this structure and the strings referenced by the members of this structure, rather than having the calling function allocate the structure and the string buffers separately.
pdwBufferSize
[in/out] A pointer to a DWORD containing the size, in bytes, of the buffer referenced by pCounterPathElements on input. On output, it receives the size of the buffer used. If the buffer size on input is zero, then no data is returned in the pCounterPathElements buffer, however, the size of the buffer required is returned in the variable referenced by this pointer.
dwFlags
Reserved. Must be zero.

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 incorrect, or this function does not have the necessary access to that argument.
PDH_INSUFFICIENT_BUFFER The buffer supplied is not large enough to accept the resulting data.
PDH_INVALID_PATH The path is not formatted correctly and cannot be parsed.
PDH_MEMORY_ALLOCATION_FAILURE A temporary buffer cannot be allocated.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Header: Declared in Pdh.h.
  Library: Use Pdh.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

PDH_COUNTER_PATH_ELEMENTS, PdhMakeCounterPath