Platform SDK: Performance Monitoring

PdhEnumMachines

The PdhEnumMachines function returns a list of the names of the machines that have been opened previously by the PDH DLL. The machines listed include those that are currently connected and online, as well as those that are offline or not returning performance data. For information about how to connect to a machine, see PdhConnectMachine.

PDH_STATUS PdhEnumMachines(
  LPCTSTR szDataSource,          
  LPTSTR mszMachineNameList,    
  LPDWORD pcchBufferLength      
);

Parameters

szDataSource
Windows 2000: [in] A pointer to a null-terminated string containing either the name of a log file or the null termination only. 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 collected from a real-time data source.

Windows NT 4.0: [in] Reserved. Must be NULL.

mszMachineNameList
[out] A pointer to a null-terminated string containing the name of the buffer, allocated by the calling function, that receives the list of MULTI_SZ strings of machines to which the PDH DLL is currently connected. This parameter may be NULL if the value referenced by pcchBufferLength is zero.
pcchBufferLength
[in/out] A pointer to a variable containing the size, in characters, of the available buffer on entry and the size of the returned buffer on exit. If the buffer size on entry is zero, then no data is returned in the mszMachineNameList buffer (and the pointer may be NULL), and the size of the buffer required, in characters, is returned in the variable pointed to by pcchBufferLength. The size returned includes both terminating NULL characters of the MULTI_SZ string.

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_MORE_DATA More data is available then the current buffer can hold. Some entries may be returned in the mszMachinenameList buffer.
PDH_INSUFFICIENT_BUFFER The buffer provided is not large enough to contain any data.
PDH_INVALID_ARGUMENT A required argument is invalid or a reserved argument is not NULL.

Remarks

The term real-time as used in the description of this function does not imply the standard meaning of the term real-time. Instead, it describes the collection of performance data from a source providing current information (for example, the registry or a WMI provider) rather than from a log file.

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

PdhConnectMachine