Platform SDK: Performance Monitoring

PdhConnectMachine

The PdhConnectMachine function connects to the specified machine, and creates and initializes a machine entry in the PDH DLL.

PDH_STATUS PdhConnectMachine(
  LPCTSTR szMachineName  
);

Parameters

szMachineName
[in] A pointer to a null-terminated string containing the name of the machine to browse. If the value of this parameter is NULL, the connection is established to the local machine.

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_CSTATUS_NO_MACHINE Unable to connect to the specified machine. Could be caused by the machine not being on, not running Windows NT/Windows 2000, not being connected to the network, or having the permissions set on the registry to not allow remote connections or remote performance monitoring by the user.
PDH_MEMORY_ALLOCATION_FAILURE Unable to allocate a dynamic memory block. Occurs when there is a serious memory shortage in the system due to too many applications running on the system or an insufficient memory paging file.

Remarks

An application can call PdhConnectMachine to establish a connection to a remote machine at a more convenient time than when the application opens a query and adds counters.

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

PdhEnumMachines