Platform SDK: Performance Monitoring |
The PdhConnectMachine function connects to the specified machine, and creates and initializes a machine entry in the PDH DLL.
PDH_STATUS PdhConnectMachine( LPCTSTR szMachineName );
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. |
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.
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.