Platform SDK: Performance Monitoring

PdhGetDefaultPerfObject

The PdhGetDefaultPerfObject function retrieves the name of the default performance object. This name can be used to select the default entry in the object browser list box.

PDH_STATUS PdhGetDefaultPerfObject(
  LPCTSTR szDataSource,        
  LPCTSTR szMachineName,       
  LPTSTR szDefaultObjectName,  
  LPDWORD pcchBufferSize       
);

Parameters

szDataSource
Windows 2000: [in] A pointer to a null-terminated string containing either the name of a log file or a null string. If you specify the name of a log file, performance data will be taken from that log file. If this parameter contains a null string, performance data will be taken from a real-time data source.

Windows NT 4.0: Reserved. Must be NULL.

szMachineName
[in] A pointer to a null-terminated string containing the name of the machine to query. If this value of this parameter is NULL, the local machine is queried.
szDefaultObjectName
[out] A pointer to a null-terminated string containing the name of the buffer that receives the fully qualified default object name. This parameter can be NULL if the value of the variable referenced by pcchBufferSize is zero.
pcchBufferSize
[in/out] A pointer to a DWORD containing the size of the szDefaultObjectName buffer, in characters, on input and the size of the returned object name on output. If the value in the variable referenced by this parameter is zero, the required buffer size, in characters, for this object name is returned in the variable and no data is 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.

Error value Description
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.

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

PdhGetDefaultPerfCounter