PdhGetDefaultPerfCounter 

The PdhGetDefaultPerfCounter function retrieves the name of the default counter for the specified object. This can be used to set the initial selection of the counter browser list/combo box.

PDH_STATUS PdhGetDefaultPerfCounter(

    IN LPCTSTR szReserved,

// reserved

    IN LPCTSTR szMachineName,

// machine to query

    IN LPCTSTR szObjectName,

// name of object

    IN LPTSTR szDefaultCounterName,

// buffer to receive counter name

    IN LPDWORD pcchBufferSize

// size of counter name

   );

 

 

Parameters

szReserved

Reserved. Must be NULL.

szMachineName

The name of the machine to query.

szObjectName

The name of the object in szMachineName to query.

szDefaultCounterName

A pointer to the buffer that will receive the default counter name for the specified object. This parameter can be NULL if the value of the DWORD referenced by pcchBufferSize is 0.

pcchBufferSize

The size of the szDefaultCounterName buffer, in characters, when called, and the size of the counter name returned on return. If the value in the DWORD pointed to by this parameter is 0, then the required buffer size, in characters, for this object name will be returned in the DWORD and no data will be copied to the buffer.

 

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:

PDH_INSUFFICIENT_BUFFER

The buffer provided is not large enough for the available data.

PDH_INVALID_ARGUMENT

A required argument is invalid or a reserved argument is not NULL.

PDH_MEMORY_ALLOCATION_FAILURE

A required temporary buffer could not be allocated.

PDH_CSTATUS_NO_MACHINE

The specified machine is offline or unavailable.

PDH_CSTATUS_NO_COUNTERNAME

The default object name cannot be read or found.

PDH_CSTATUS_NO_OBJECT

The specified object could not be found on the specified machine.

PDH_CSTATUS_NO_COUNTER

The default counter was not found in the specified object.

 

See Also

PdhGetDefaultPerfObject