Group: Terminal Services - Library: wtsapi32
How to enumerate sessions and processes on a specified terminal server
HANDLE WTSOpenServer(
LPTSTR pServerName
);
DECLARE INTEGER WTSOpenServer IN Wtsapi32;
STRING pServerName
pServerName [in] Pointer to a null-terminated string specifying the NetBIOS name of the terminal server.
If the function succeeds, the return value is a handle to the specified server.
When you are finished with the handle returned by WTSOpenServer, call the WTSCloseServer function to close it.
You do not need to open a handle for operations performed on the terminal server on which your application is running. Use the constant WTS_CURRENT_SERVER_HANDLE instead.