PdhMakeCounterPath 

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

PDH_STATUS PdhMakeCounterPath(

    IN PDH_COUNTER_PATH_ELEMENTS *pCounterPathElements,

// counter path elements

    IN LPTSTR szFullPathBuffer,

// path string buffer

    IN LPDWORD pcchBufferSize,

// size of buffer

    IN DWORD dwFlags

// reserved

   );

 

 

Parameters

*pCounterPathElements

Pointer to a PDH_COUNTER_PATH_ELEMENTSC.AJHD 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

LPTSTR szMachineName

optional

LPTSTR szObjectName

required

LPTSTR szInstanceName

optional

LPTSTR szParentInstance

optional

DWORD dwInstanceIndex

optional
((DWORD)
-1 if no index)

LPTSTR 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

The buffer allocated by the caller that will receive the full path string created by this function.

pcchBufferSize

A pointer to the DWORD containing the size, in bytes, of the available buffer, and which returns with the size of the buffer used. If the buffer size on entry is zero, then no data is returned in the szFullPathBuffer buffer, however, the size of the buffer required is returned in the DWORD. The size returned includes the terminating NULL character of the string.

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.

See Also

PDH_COUNTER_PATH_ELEMENTS, PdhParseCounterPath