Terminal service (translation) (1)
Recently, because the company's requirements develop a program in the terminal environment, I find a lot of information and websites, but there is almost no materials in this area, only some English materials above MSDN, I translated part of the publication Sharing with everyone, I hope that the master of this expert will put forward your valuable opinions, I am here, thank you.
Use Terminal Services API:
This section describes the use of the terminal service API to complete the following tasks:
l Execute a terminal service management task. For example, listed all terminal servers in a domain, enumerate all sessions and processes that manage a terminal server.
l Enhances the functionality of a client / service mode program in a terminal service environment.
l Use the terminal virtual channel to communicate with the service component in a program.
l Set or retrieve a special terminal service registered user configuration information.
If your program runs in non-terminal environments, you want to use the terminal service API enhancement program in a terminal environment, please see Run-Time Linking to wtsapi32.dll.
I. Terminal service management
Terminal Services API functions allow you to enumerate all terminal servers, customer sessions, and processes.
In order to get the name of all terminal servers in a domain, you can adjust the NetServereNum function to list all SV_TYPE_TERMINALRERVER types of terminal servers. Call the wtsopenserver function by passing a terminal server, you can open a handle of a special terminal server. You can call the WTSCloseServer function to close it after completing the operation.
You can use the terminal server handle returned by the WTSopenserver function to perform the following operations in the server:
Function Operation WTSDisConnectSession opens user connections from a special session, but this session still exists, and users can log in again and connect this session. WTSenumerateSession returns a list of all sessions in a special terminal server WtsenumerateProcesses Returns a list of all processes in a special terminal server WTSLogoffSession Log in to a special session wtsquerysessionInformation Retrieves a special session in a special terminal server WTssendMessage A message is displayed on a client display under a special session. WTSSHUTDOWNSYSTEM off or starts a terminal server WTSTERMINATEPROCESS End a special process of Terminal Server WTSVirtualChannelOpen opens a handle of a special virtual terminal server. To get more information, please pay attention to Useing Terminal Services Virtual Channels. WTSWaitsystemEvent Wait for an event, such as a customer session creation, one user logs in to a terminal server.
Some of the above functions are assigned a buffer to return information to the call, please use after using these buffers.
WTSFreeMemory
The function releases these memory resources.