Platform SDK: Performance Monitoring

PdhMakeCounterPath

The PdhMakeCounterPath function creates a full counter path using the members specified in the structure passed in the parameter list.

PDH_STATUS PdhMakeCounterPath(
  PDH_COUNTER_PATH_ELEMENTS *pCounterPathElements,
  LPTSTR szFullPathBuffer,  
  LPDWORD pcchBufferSize,   
  DWORD dwFlags             
);

Parameters

pCounterPathElements
[in] A pointer to a PDH_COUNTER_PATH_ELEMENTS structure that contains the individual members that are to make up the path. The following table indicates which members are required and which are optional.
Member Required or optional
szMachineName optional
szObjectName required
szInstanceName optional
szParentInstance optional
dwInstanceIndex optional
((DWORD)–1 if no index)
szCounterName required

If a required member is not present, then no path string will be constructed. If the szMachineName member is NULL, then no machine name will be included in the path (a generic path will be created). If the instance name argument is NULL, then no instance reference will be inserted into the path string and the szParentInstance and the dwInstanceIndex members will be ignored.

szFullPathBuffer
[out] A pointer to a null-terminated string containing the name of the buffer allocated by the caller that receives the full path string.
pcchBufferSize
[in/out] A pointer to a DWORD containing the size, in bytes, of the available buffer on input. On output, receives the size of the buffer used. If the buffer size on input is zero, then no data is returned in the szFullPathBuffer buffer, however, the size of the buffer required is returned in the variable. The size returned includes the terminating NULL character of the string.
dwFlags
[in] The format of the input and output counter values. This parameter can be one of the following values.
Value Description
PDH_PATH_WBEM_RESULT Windows 2000: The path is returned as in WMI format.
PDH_PATH_WBEM_INPUT Windows 2000: The input is assumed to be in WMI format.
0 The path is returned as a list of registry path items.

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_INSUFFICIENT_BUFFER The buffer is not large enough to contain any data.
PDH_INVALID_ARGUMENT An argument is not correct or is incorrectly formatted.

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, PdhParseCounterPath