OSDN Git Service

Correct mistyped __MINGW_NOTHROW macro.
[mingw/mingw-org-wsl.git] / include / wtsapi32.h
1 /**
2  * @file wtsapi32.h
3  * Copyright 2012, 2013 MinGW.org project
4  *
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:
11  * 
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
14  * Software.
15  * 
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.
23  */
24 #ifndef _WTSAPI32_H
25 #define _WTSAPI32_H
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN2K)
34 typedef struct _WTS_SESSION_INFOW {
35   DWORD SessionId;
36   LPWSTR pWinStationName;
37   WTS_CONNECTSTATE_CLASS State;
38 } WTS_SESSION_INFOW, *PWTS_SESSION_INFOW;
39
40 typedef struct _WTS_SESSION_INFOA {
41   DWORD SessionId;
42   LPSTR pWinStationName;
43   WTS_CONNECTSTATE_CLASS State;
44 } WTS_SESSION_INFOA, *PWTS_SESSION_INFOA;
45
46 #define WTS_SESSION_INFO        __AW(WTS_SESSION_INFO)
47 #define PWTS_SESSION_INFO       __AW(PWTS_SESSION_INFO)
48
49   // WTSWaitSystemEvent local server handle
50 #define WTS_CURRENT_SERVER_HANDLE 0
51 #define WTS_CURRENT_SESSION       ((DWORD)-1)
52
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
66
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,
75                                   PDWORD pCount);
76 BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version,
77                                   PWTS_SESSION_INFOA *ppSessionInfo,
78                                   PDWORD pCount);
79 void WINAPI WTSFreeMemory(PVOID pMemory);
80
81 #define WTSEnumerateSessions __AW(WTSEnumerateSessions)
82 #define WTSQuerySessionInformation __AW(WTSQuerySessionInformation)
83
84 BOOL WTSSendMessageA(
85   HANDLE hServer,
86   DWORD SessionId,
87   LPSTR pTitle,
88   DWORD TitleLength,
89   LPSTR pMessage,
90   DWORD MessageLength,
91   DWORD Style,
92   DWORD Timeout,
93   DWORD *pResponse,
94   BOOL bWait
95 );
96
97 BOOL WTSSendMessageW(
98   HANDLE hServer,
99   DWORD SessionId,
100   LPWSTR pTitle,
101   DWORD TitleLength,
102   LPWSTR pMessage,
103   DWORD MessageLength,
104   DWORD Style,
105   DWORD Timeout,
106   DWORD *pResponse,
107   BOOL bWait
108 );
109
110 #define WTSSendMessage __AW(WTSSendMessage)
111
112 BOOL WTSVirtualChannelClose(
113   __in  HANDLE hChannelHandle
114 );
115
116 HANDLE WTSVirtualChannelOpen(
117   __in  HANDLE hServer,
118   __in  DWORD SessionId,
119   __in  LPSTR pVirtualName
120 );
121
122 BOOL WTSVirtualChannelPurgeInput(
123   __in  HANDLE hChannelHandle
124 );
125
126 BOOL WTSVirtualChannelPurgeOutput(
127   __in  HANDLE hChannelHandle
128 );
129
130 BOOL WTSVirtualChannelRead(
131   __in   HANDLE hChannelHandle,
132   __in   ULONG TimeOut,
133   __out  PCHAR Buffer,
134   __in   ULONG BufferSize,
135   __out  PULONG pBytesRead
136 );
137
138 BOOL WTSVirtualChannelWrite(
139   __in   HANDLE hChannelHandle,
140   __in   PCHAR Buffer,
141   __in   ULONG Length,
142   __out  PULONG pBytesWritten
143 );
144 #endif /* _WIN32_WINNT >= _WIN32_WINNT_WIN2K */
145
146 #if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
147   // session notification message
148 #define WM_WTSSESSION_CHANGE            0x02B1
149
150 typedef enum _WTS_INFO_CLASS {
151   WTSInitialProgram       = 0,
152   WTSApplicationName      = 1,
153   WTSWorkingDirectory     = 2,
154   WTSOEMId                = 3,
155   WTSSessionId            = 4,
156   WTSUserName             = 5,
157   WTSWinStationName       = 6,
158   WTSDomainName           = 7,
159   WTSConnectState         = 8,
160   WTSClientBuildNumber    = 9,
161   WTSClientName           = 10,
162   WTSClientDirectory      = 11,
163   WTSClientProductId      = 12,
164   WTSClientHardwareId     = 13,
165   WTSClientAddress        = 14,
166   WTSClientDisplay        = 15,
167   WTSClientProtocolType   = 16,
168   WTSIdleTime             = 17,
169   WTSLogonTime            = 18,
170   WTSIncomingBytes        = 19,
171   WTSOutgoingBytes        = 20,
172   WTSIncomingFrames       = 21,
173   WTSOutgoingFrames       = 22,
174   WTSClientInfo           = 23,
175   WTSSessionInfo          = 24
176 } WTS_INFO_CLASS;
177
178 typedef enum _WTS_CONNECTSTATE_CLASS {
179   WTSActive,
180   WTSConnected,
181   WTSConnectQuery,
182   WTSShadow,
183   WTSDisconnected,
184   WTSIdle,
185   WTSListen,
186   WTSReset,
187   WTSDown,
188   WTSInit 
189 } WTS_CONNECTSTATE_CLASS;
190
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
201
202   // WTSRegisterSessionNotifiction flags
203 #define NOTIFY_FOR_THIS_SESSION         0
204 #define NOTIFY_FOR_ALL_SESSIONS         1
205
206 BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags);
207 BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd);
208 BOOL WINAPI WTSQueryUserToken(ULONG SessionId, PHANDLE pToken);
209
210 BOOL WTSVirtualChannelQuery(
211   __in   HANDLE hChannelHandle,
212   __in   WTS_VIRTUAL_CLASS WtsVirtualClass,
213   __out  PVOID *ppBuffer,
214   __out  DWORD *pBytesReturned
215 );
216 #endif /* _WIN32_WINNT >= _WIN32_WINNT_WINXP */
217
218 #if _WIN32_WINNT >= _WIN32_WINNT_VISTA
219 HANDLE WTSVirtualChannelOpenEx(
220   __in  DWORD SessionId,
221   __in  LPSTR pVirtualName,
222   __in  DWORD flags
223 );
224 #endif
225
226 #ifdef __cplusplus
227 }
228 #endif
229
230 #endif /* _WTSAPI32_H */