3 * Copyright 2012, 2013 MinGW.org project
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
26 #pragma GCC system_header
33 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN2K)
34 typedef struct _WTS_SESSION_INFOW {
36 LPWSTR pWinStationName;
37 WTS_CONNECTSTATE_CLASS State;
38 } WTS_SESSION_INFOW, *PWTS_SESSION_INFOW;
40 typedef struct _WTS_SESSION_INFOA {
42 LPSTR pWinStationName;
43 WTS_CONNECTSTATE_CLASS State;
44 } WTS_SESSION_INFOA, *PWTS_SESSION_INFOA;
46 #define WTS_SESSION_INFO __AW(WTS_SESSION_INFO)
47 #define PWTS_SESSION_INFO __AW(PWTS_SESSION_INFO)
49 // WTSWaitSystemEvent local server handle
50 #define WTS_CURRENT_SERVER_HANDLE 0
51 #define WTS_CURRENT_SESSION ((DWORD)-1)
53 // WTSWaitSystemEvent flags
54 #define WTS_EVENT_NONE 0x00000000
55 #define WTS_EVENT_CREATE 0x00000001
56 #define WTS_EVENT_DELETE 0x00000002
57 #define WTS_EVENT_RENAME 0x00000004
58 #define WTS_EVENT_CONNECT 0x00000008
59 #define WTS_EVENT_DISCONNECT 0x00000010
60 #define WTS_EVENT_LOGON 0x00000020
61 #define WTS_EVENT_LOGOFF 0x00000040
62 #define WTS_EVENT_STATECHANGE 0x00000080
63 #define WTS_EVENT_LICENSE 0x00000100
64 #define WTS_EVENT_ALL 0x7FFFFFFF
65 #define WTS_EVENT_FLUSH 0x80000000
67 BOOL WINAPI WTSQuerySessionInformationA(HANDLE hServer, DWORD SessionId, WTS_INFO_CLASS WTSInfoClass,
68 LPSTR *ppBuffer, DWORD *pBytesReturned);
69 BOOL WINAPI WTSQuerySessionInformationW(HANDLE hServer, DWORD SessionId, WTS_INFO_CLASS WTSInfoClass,
70 LPTSTR *ppBuffer, DWORD *pBytesReturned);
71 BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags);
72 BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId, BOOL bWait);
73 BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version,
74 PWTS_SESSION_INFOW *ppSessionInfo,
76 BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version,
77 PWTS_SESSION_INFOA *ppSessionInfo,
79 void WINAPI WTSFreeMemory(PVOID pMemory);
81 #define WTSEnumerateSessions __AW(WTSEnumerateSessions)
82 #define WTSQuerySessionInformation __AW(WTSQuerySessionInformation)
110 #define WTSSendMessage __AW(WTSSendMessage)
112 BOOL WTSVirtualChannelClose(
113 __in HANDLE hChannelHandle
116 HANDLE WTSVirtualChannelOpen(
118 __in DWORD SessionId,
119 __in LPSTR pVirtualName
122 BOOL WTSVirtualChannelPurgeInput(
123 __in HANDLE hChannelHandle
126 BOOL WTSVirtualChannelPurgeOutput(
127 __in HANDLE hChannelHandle
130 BOOL WTSVirtualChannelRead(
131 __in HANDLE hChannelHandle,
134 __in ULONG BufferSize,
135 __out PULONG pBytesRead
138 BOOL WTSVirtualChannelWrite(
139 __in HANDLE hChannelHandle,
142 __out PULONG pBytesWritten
144 #endif /* _WIN32_WINNT >= _WIN32_WINNT_WIN2K */
146 #if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
147 // session notification message
148 #define WM_WTSSESSION_CHANGE 0x02B1
150 typedef enum _WTS_INFO_CLASS {
151 WTSInitialProgram = 0,
152 WTSApplicationName = 1,
153 WTSWorkingDirectory = 2,
157 WTSWinStationName = 6,
160 WTSClientBuildNumber = 9,
162 WTSClientDirectory = 11,
163 WTSClientProductId = 12,
164 WTSClientHardwareId = 13,
165 WTSClientAddress = 14,
166 WTSClientDisplay = 15,
167 WTSClientProtocolType = 16,
170 WTSIncomingBytes = 19,
171 WTSOutgoingBytes = 20,
172 WTSIncomingFrames = 21,
173 WTSOutgoingFrames = 22,
178 typedef enum _WTS_CONNECTSTATE_CLASS {
189 } WTS_CONNECTSTATE_CLASS;
191 // session notification message flags
192 #define WTS_CONSOLE_CONNECT 0x1
193 #define WTS_CONSOLE_DISCONNECT 0x2
194 #define WTS_REMOTE_CONNECT 0x3
195 #define WTS_REMOTE_DISCONNECT 0x4
196 #define WTS_SESSION_LOGON 0x5
197 #define WTS_SESSION_LOGOFF 0x6
198 #define WTS_SESSION_LOCK 0x7
199 #define WTS_SESSION_UNLOCK 0x8
200 #define WTS_SESSION_REMOTE_CONTROL 0x9
202 // WTSRegisterSessionNotifiction flags
203 #define NOTIFY_FOR_THIS_SESSION 0
204 #define NOTIFY_FOR_ALL_SESSIONS 1
206 BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags);
207 BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd);
208 BOOL WINAPI WTSQueryUserToken(ULONG SessionId, PHANDLE pToken);
210 BOOL WTSVirtualChannelQuery(
211 __in HANDLE hChannelHandle,
212 __in WTS_VIRTUAL_CLASS WtsVirtualClass,
213 __out PVOID *ppBuffer,
214 __out DWORD *pBytesReturned
216 #endif /* _WIN32_WINNT >= _WIN32_WINNT_WINXP */
218 #if _WIN32_WINNT >= _WIN32_WINNT_VISTA
219 HANDLE WTSVirtualChannelOpenEx(
220 __in DWORD SessionId,
221 __in LPSTR pVirtualName,
230 #endif /* _WTSAPI32_H */