2bea36c6941ef0d69d9c535fa37acc8670e601cb
[reactos.git] / include / psdk / wincon.h
1 #ifndef _WINCON_H
2 #define _WINCON_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #if (_WIN32_WINNT >= 0x0600) && !defined(NOGDI)
9 # include "wingdi.h"
10 #endif
11
12 #ifdef _MSC_VER
13 #pragma warning(push)
14 #pragma warning(disable:4820)
15 #endif
16
17 #define FOREGROUND_BLUE 1
18 #define FOREGROUND_GREEN 2
19 #define FOREGROUND_RED 4
20 #define FOREGROUND_INTENSITY 8
21 #define BACKGROUND_BLUE 16
22 #define BACKGROUND_GREEN 32
23 #define BACKGROUND_RED 64
24 #define BACKGROUND_INTENSITY 128
25 #define CTRL_C_EVENT 0
26 #define CTRL_BREAK_EVENT 1
27 #define CTRL_CLOSE_EVENT 2
28 #define CTRL_LOGOFF_EVENT 5
29 #define CTRL_SHUTDOWN_EVENT 6
30 #define ENABLE_LINE_INPUT 2
31 #define ENABLE_ECHO_INPUT 4
32 #define ENABLE_PROCESSED_INPUT 1
33 #define ENABLE_WINDOW_INPUT 8
34 #define ENABLE_MOUSE_INPUT 16
35 #define ENABLE_PROCESSED_OUTPUT 1
36 #define ENABLE_WRAP_AT_EOL_OUTPUT 2
37 #define KEY_EVENT 1
38 #define MOUSE_EVENT 2
39 #define WINDOW_BUFFER_SIZE_EVENT 4
40 #define MENU_EVENT 8
41 #define FOCUS_EVENT 16
42 #define CAPSLOCK_ON 128
43 #define ENHANCED_KEY 256
44 #define RIGHT_ALT_PRESSED 1
45 #define LEFT_ALT_PRESSED 2
46 #define RIGHT_CTRL_PRESSED 4
47 #define LEFT_CTRL_PRESSED 8
48 #define SHIFT_PRESSED 16
49 #define NUMLOCK_ON 32
50 #define SCROLLLOCK_ON 64
51 #define FROM_LEFT_1ST_BUTTON_PRESSED 1
52 #define RIGHTMOST_BUTTON_PRESSED 2
53 #define FROM_LEFT_2ND_BUTTON_PRESSED 4
54 #define FROM_LEFT_3RD_BUTTON_PRESSED 8
55 #define FROM_LEFT_4TH_BUTTON_PRESSED 16
56 #define MOUSE_MOVED 1
57 #define DOUBLE_CLICK 2
58 #define MOUSE_WHEELED 4
59
60 typedef struct _CONSOLE_READCONSOLE_CONTROL {
61 ULONG nLength;
62 ULONG nInitialChars;
63 ULONG dwCtrlWakeupMask;
64 ULONG dwControlKeyState;
65 } CONSOLE_READCONSOLE_CONTROL, *PCONSOLE_READCONSOLE_CONTROL;
66
67 typedef struct _CHAR_INFO {
68 union {
69 WCHAR UnicodeChar;
70 CHAR AsciiChar;
71 } Char;
72 WORD Attributes;
73 } CHAR_INFO,*PCHAR_INFO;
74 typedef struct _SMALL_RECT {
75 SHORT Left;
76 SHORT Top;
77 SHORT Right;
78 SHORT Bottom;
79 } SMALL_RECT,*PSMALL_RECT;
80 typedef struct _CONSOLE_CURSOR_INFO {
81 DWORD dwSize;
82 BOOL bVisible;
83 } CONSOLE_CURSOR_INFO,*PCONSOLE_CURSOR_INFO;
84 typedef struct _COORD {
85 SHORT X;
86 SHORT Y;
87 } COORD, *PCOORD;
88 typedef struct _CONSOLE_SELECTION_INFO {
89 DWORD dwFlags;
90 COORD dwSelectionAnchor;
91 SMALL_RECT srSelection;
92 } CONSOLE_SELECTION_INFO, *PCONSOLE_SELECTION_INFO;
93 typedef struct _CONSOLE_FONT_INFO {
94 DWORD nFont;
95 COORD dwFontSize;
96 } CONSOLE_FONT_INFO, *PCONSOLE_FONT_INFO;
97 typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
98 COORD dwSize;
99 COORD dwCursorPosition;
100 WORD wAttributes;
101 SMALL_RECT srWindow;
102 COORD dwMaximumWindowSize;
103 } CONSOLE_SCREEN_BUFFER_INFO,*PCONSOLE_SCREEN_BUFFER_INFO;
104 typedef BOOL(CALLBACK *PHANDLER_ROUTINE)(_In_ DWORD);
105 typedef struct _KEY_EVENT_RECORD {
106 BOOL bKeyDown;
107 WORD wRepeatCount;
108 WORD wVirtualKeyCode;
109 WORD wVirtualScanCode;
110 union {
111 WCHAR UnicodeChar;
112 CHAR AsciiChar;
113 } uChar;
114 DWORD dwControlKeyState;
115 }
116 #ifdef __GNUC__
117 /* gcc's alignment is not what win32 expects */
118 PACKED
119 #endif
120 KEY_EVENT_RECORD;
121 typedef struct _MOUSE_EVENT_RECORD {
122 COORD dwMousePosition;
123 DWORD dwButtonState;
124 DWORD dwControlKeyState;
125 DWORD dwEventFlags;
126 } MOUSE_EVENT_RECORD;
127 typedef struct _WINDOW_BUFFER_SIZE_RECORD { COORD dwSize; } WINDOW_BUFFER_SIZE_RECORD;
128 typedef struct _MENU_EVENT_RECORD { UINT dwCommandId; } MENU_EVENT_RECORD,*PMENU_EVENT_RECORD;
129 typedef struct _FOCUS_EVENT_RECORD { BOOL bSetFocus; } FOCUS_EVENT_RECORD;
130 typedef struct _INPUT_RECORD {
131 WORD EventType;
132 union {
133 KEY_EVENT_RECORD KeyEvent;
134 MOUSE_EVENT_RECORD MouseEvent;
135 WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
136 MENU_EVENT_RECORD MenuEvent;
137 FOCUS_EVENT_RECORD FocusEvent;
138 } Event;
139 } INPUT_RECORD,*PINPUT_RECORD;
140
141 #if (_WIN32_WINNT >= 0x0600)
142 #define HISTORY_NO_DUP_FLAG 0x1
143 #define CONSOLE_OVERSTRIKE 0x1
144
145 typedef struct _CONSOLE_HISTORY_INFO {
146 UINT cbSize;
147 UINT HistoryBufferSize;
148 UINT NumberOfHistoryBuffers;
149 DWORD dwFlags;
150 } CONSOLE_HISTORY_INFO, *PCONSOLE_HISTORY_INFO;
151
152 typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX {
153 ULONG cbSize;
154 COORD dwSize;
155 COORD dwCursorPosition;
156 WORD wAttributes;
157 SMALL_RECT srWindow;
158 COORD dwMaximumWindowSize;
159 WORD wPopupAttributes;
160 COLORREF ColorTable[16];
161 } CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX;
162
163 #ifndef NOGDI
164 typedef struct _CONSOLE_FONT_INFOEX {
165 ULONG cbSize;
166 DWORD nFont;
167 COORD dwFontSize;
168 UINT FontFamily;
169 UINT FontWeight;
170 WCHAR FaceName[LF_FACESIZE];
171 } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
172 #endif
173 #endif
174
175 BOOL WINAPI AllocConsole(void);
176 #if (_WIN32_WINNT >= 0x0501)
177 #define ATTACH_PARENT_PROCESS (DWORD)-1
178 BOOL WINAPI AttachConsole(_In_ DWORD);
179 BOOL WINAPI AddConsoleAliasA(_In_ LPCSTR, _In_ LPCSTR, _In_ LPCSTR);
180 BOOL WINAPI AddConsoleAliasW(_In_ LPCWSTR, _In_ LPCWSTR, _In_ LPCWSTR);
181
182 DWORD
183 WINAPI
184 GetConsoleAliasA(
185 _In_ LPSTR Source,
186 _Out_writes_(TargetBufferLength) LPSTR TargetBuffer,
187 _In_ DWORD TargetBufferLength,
188 _In_ LPSTR ExeName);
189
190 DWORD
191 WINAPI
192 GetConsoleAliasW(
193 _In_ LPWSTR Source,
194 _Out_writes_(TargetBufferLength) LPWSTR TargetBuffer,
195 _In_ DWORD TargetBufferLength,
196 _In_ LPWSTR ExeName);
197
198 DWORD
199 WINAPI
200 GetConsoleAliasesA(
201 _Out_writes_(AliasBufferLength) LPSTR AliasBuffer,
202 _In_ DWORD AliasBufferLength,
203 _In_ LPSTR ExeName);
204
205 DWORD
206 WINAPI
207 GetConsoleAliasesW(
208 _Out_writes_(AliasBufferLength) LPWSTR AliasBuffer,
209 _In_ DWORD AliasBufferLength,
210 _In_ LPWSTR ExeName);
211
212 DWORD WINAPI GetConsoleAliasesLengthA(_In_ LPSTR);
213 DWORD WINAPI GetConsoleAliasesLengthW(_In_ LPWSTR);
214 #endif
215 HANDLE WINAPI CreateConsoleScreenBuffer(_In_ DWORD, _In_ DWORD, _In_opt_ CONST SECURITY_ATTRIBUTES*, _In_ DWORD, _Reserved_ LPVOID);
216 BOOL WINAPI FillConsoleOutputAttribute(_In_ HANDLE, _In_ WORD, _In_ DWORD, _In_ COORD, _Out_ PDWORD);
217 BOOL WINAPI FillConsoleOutputCharacterA(_In_ HANDLE, _In_ CHAR, _In_ DWORD, _In_ COORD, _Out_ PDWORD);
218 BOOL WINAPI FillConsoleOutputCharacterW(_In_ HANDLE, _In_ WCHAR, _In_ DWORD, _In_ COORD, _Out_ PDWORD);
219 BOOL WINAPI FlushConsoleInputBuffer(_In_ HANDLE);
220 BOOL WINAPI FreeConsole(void);
221 BOOL WINAPI GenerateConsoleCtrlEvent(_In_ DWORD, _In_ DWORD);
222 UINT WINAPI GetConsoleCP(void);
223 BOOL WINAPI GetConsoleCursorInfo(_In_ HANDLE, _Out_ PCONSOLE_CURSOR_INFO);
224 BOOL WINAPI GetConsoleMode(HANDLE,PDWORD);
225 UINT WINAPI GetConsoleOutputCP(void);
226 BOOL WINAPI GetConsoleScreenBufferInfo(_In_ HANDLE, _Out_ PCONSOLE_SCREEN_BUFFER_INFO);
227
228 DWORD
229 WINAPI
230 GetConsoleTitleA(
231 _Out_writes_(nSize) LPSTR lpConsoleTitle,
232 _In_ DWORD nSize);
233
234 DWORD
235 WINAPI
236 GetConsoleTitleW(
237 _Out_writes_(nSize) LPWSTR lpConsoleTitle,
238 _In_ DWORD nSize);
239
240 #if (_WIN32_WINNT >= 0x0500)
241 HWND WINAPI GetConsoleWindow(void);
242 WINBASEAPI BOOL APIENTRY GetConsoleDisplayMode(_Out_ LPDWORD lpModeFlags);
243 BOOL APIENTRY SetConsoleDisplayMode(_In_ HANDLE hConsoleOutput, _In_ DWORD dwFlags, _Out_opt_ PCOORD lpNewScreenBufferDimensions);
244 #endif
245 COORD WINAPI GetLargestConsoleWindowSize(_In_ HANDLE);
246 BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE,PDWORD);
247 BOOL WINAPI GetNumberOfConsoleMouseButtons(_Out_ PDWORD);
248 BOOL WINAPI PeekConsoleInputA(HANDLE,PINPUT_RECORD,DWORD,PDWORD);
249
250 BOOL
251 WINAPI
252 PeekConsoleInputW(
253 _In_ HANDLE hConsoleInput,
254 _Out_writes_(nLength) PINPUT_RECORD lpBuffer,
255 _In_ DWORD nLength,
256 _Out_ LPDWORD lpNumberOfEventsRead);
257
258 BOOL WINAPI ReadConsoleA(HANDLE,PVOID,DWORD,PDWORD,PCONSOLE_READCONSOLE_CONTROL);
259 BOOL WINAPI ReadConsoleW(HANDLE,PVOID,DWORD,PDWORD,PCONSOLE_READCONSOLE_CONTROL);
260 BOOL WINAPI ReadConsoleInputA(HANDLE,PINPUT_RECORD,DWORD,PDWORD);
261 BOOL WINAPI ReadConsoleInputW(HANDLE,PINPUT_RECORD,DWORD,PDWORD);
262
263 BOOL
264 WINAPI
265 ReadConsoleOutputAttribute(
266 _In_ HANDLE hConsoleOutput,
267 _Out_writes_(nLength) LPWORD lpAttribute,
268 _In_ DWORD nLength,
269 _In_ COORD dwReadCoord,
270 _Out_ LPDWORD lpNumberOfAttrsRead);
271
272 BOOL
273 WINAPI
274 ReadConsoleOutputCharacterA(
275 _In_ HANDLE hConsoleOutput,
276 _Out_writes_(nLength) LPSTR lpCharacter,
277 _In_ DWORD nLength,
278 _In_ COORD dwReadCoord,
279 _Out_ LPDWORD lpNumberOfCharsRead);
280
281 BOOL
282 WINAPI
283 ReadConsoleOutputCharacterW(
284 _In_ HANDLE hConsoleOutput,
285 _Out_writes_(nLength) LPWSTR lpCharacter,
286 _In_ DWORD nLength,
287 _In_ COORD dwReadCoord,
288 _Out_ LPDWORD lpNumberOfCharsRead);
289
290 BOOL
291 WINAPI
292 ReadConsoleOutputA(
293 _In_ HANDLE hConsoleOutput,
294 _Out_writes_(dwBufferSize.X * dwBufferSize.Y) PCHAR_INFO lpBuffer,
295 _In_ COORD dwBufferSize,
296 _In_ COORD dwBufferCoord,
297 _Inout_ PSMALL_RECT lpReadRegion);
298
299 BOOL
300 WINAPI
301 ReadConsoleOutputW(
302 _In_ HANDLE hConsoleOutput,
303 _Out_writes_(dwBufferSize.X * dwBufferSize.Y) PCHAR_INFO lpBuffer,
304 _In_ COORD dwBufferSize,
305 _In_ COORD dwBufferCoord,
306 _Inout_ PSMALL_RECT lpReadRegion);
307
308 BOOL WINAPI ScrollConsoleScreenBufferA(_In_ HANDLE, _In_ const SMALL_RECT*, _In_opt_ const SMALL_RECT*, _In_ COORD, _In_ const CHAR_INFO*);
309 BOOL WINAPI ScrollConsoleScreenBufferW(_In_ HANDLE, _In_ const SMALL_RECT*, _In_opt_ const SMALL_RECT*, _In_ COORD, _In_ const CHAR_INFO*);
310 BOOL WINAPI SetConsoleActiveScreenBuffer(_In_ HANDLE);
311 BOOL WINAPI SetConsoleCP(_In_ UINT);
312 BOOL WINAPI SetConsoleCtrlHandler(PHANDLER_ROUTINE,BOOL);
313 BOOL WINAPI SetConsoleCursorInfo(_In_ HANDLE, _In_ const CONSOLE_CURSOR_INFO*);
314 BOOL WINAPI SetConsoleCursorPosition(_In_ HANDLE, _In_ COORD);
315 BOOL WINAPI SetConsoleMode(HANDLE,DWORD);
316 BOOL WINAPI SetConsoleOutputCP(_In_ UINT);
317 BOOL WINAPI SetConsoleScreenBufferSize(_In_ HANDLE, _In_ COORD);
318 BOOL WINAPI SetConsoleTextAttribute(_In_ HANDLE, _In_ WORD);
319 BOOL WINAPI SetConsoleTitleA(_In_ LPCSTR);
320 BOOL WINAPI SetConsoleTitleW(_In_ LPCWSTR);
321 BOOL WINAPI SetConsoleWindowInfo(_In_ HANDLE, _In_ BOOL, _In_ const SMALL_RECT*);
322 BOOL WINAPI WriteConsoleA(HANDLE,CONST VOID*,DWORD,LPDWORD,LPVOID);
323 BOOL WINAPI WriteConsoleW(HANDLE,CONST VOID*,DWORD,LPDWORD,LPVOID);
324
325 BOOL
326 WINAPI
327 WriteConsoleInputA(
328 _In_ HANDLE hConsoleInput,
329 _In_reads_(nLength) CONST INPUT_RECORD *lpBuffer,
330 _In_ DWORD nLength,
331 _Out_ LPDWORD lpNumberOfEventsWritten);
332
333 BOOL
334 WINAPI
335 WriteConsoleInputW(
336 _In_ HANDLE hConsoleInput,
337 _In_reads_(nLength) CONST INPUT_RECORD *lpBuffer,
338 _In_ DWORD nLength,
339 _Out_ LPDWORD lpNumberOfEventsWritten);
340
341 BOOL
342 WINAPI
343 WriteConsoleOutputA(
344 _In_ HANDLE hConsoleOutput,
345 _In_reads_(dwBufferSize.X * dwBufferSize.Y) CONST CHAR_INFO *lpBuffer,
346 _In_ COORD dwBufferSize,
347 _In_ COORD dwBufferCoord,
348 _Inout_ PSMALL_RECT lpWriteRegion);
349
350 BOOL
351 WINAPI
352 WriteConsoleOutputW(
353 _In_ HANDLE hConsoleOutput,
354 _In_reads_(dwBufferSize.X * dwBufferSize.Y) CONST CHAR_INFO *lpBuffer,
355 _In_ COORD dwBufferSize,
356 _In_ COORD dwBufferCoord,
357 _Inout_ PSMALL_RECT lpWriteRegion);
358
359 BOOL
360 WINAPI
361 WriteConsoleOutputAttribute(
362 _In_ HANDLE hConsoleOutput,
363 _In_reads_(nLength) CONST WORD *lpAttribute,
364 _In_ DWORD nLength,
365 _In_ COORD dwWriteCoord,
366 _Out_ LPDWORD lpNumberOfAttrsWritten);
367
368 BOOL
369 WINAPI
370 WriteConsoleOutputCharacterA(
371 _In_ HANDLE hConsoleOutput,
372 _In_reads_(nLength) LPCSTR lpCharacter,
373 _In_ DWORD nLength,
374 _In_ COORD dwWriteCoord,
375 _Out_ LPDWORD lpNumberOfCharsWritten);
376
377 BOOL
378 WINAPI
379 WriteConsoleOutputCharacterW(
380 _In_ HANDLE hConsoleOutput,
381 _In_reads_(nLength) LPCWSTR lpCharacter,
382 _In_ DWORD nLength,
383 _In_ COORD dwWriteCoord,
384 _Out_ LPDWORD lpNumberOfCharsWritten);
385
386 #define CONSOLE_FULLSCREEN 1
387 #define CONSOLE_FULLSCREEN_HARDWARE 2
388 #define CONSOLE_FULLSCREEN_MODE 1
389 #define CONSOLE_WINDOWED_MODE 2
390
391 #ifdef UNICODE
392 #define FillConsoleOutputCharacter FillConsoleOutputCharacterW
393 #define AddConsoleAlias AddConsoleAliasW
394 #define GetConsoleAlias GetConsoleAliasW
395 #define GetConsoleAliases GetConsoleAliasesW
396 #define GetConsoleAliasesLength GetConsoleAliasesLengthW
397 #define GetConsoleTitle GetConsoleTitleW
398 #define PeekConsoleInput PeekConsoleInputW
399 #define ReadConsole ReadConsoleW
400 #define ReadConsoleInput ReadConsoleInputW
401 #define ReadConsoleOutput ReadConsoleOutputW
402 #define ReadConsoleOutputCharacter ReadConsoleOutputCharacterW
403 #define ScrollConsoleScreenBuffer ScrollConsoleScreenBufferW
404 #define SetConsoleTitle SetConsoleTitleW
405 #define WriteConsole WriteConsoleW
406 #define WriteConsoleInput WriteConsoleInputW
407 #define WriteConsoleOutput WriteConsoleOutputW
408 #define WriteConsoleOutputCharacter WriteConsoleOutputCharacterW
409 #else
410 #define AddConsoleAlias AddConsoleAliasA
411 #define FillConsoleOutputCharacter FillConsoleOutputCharacterA
412 #define GetConsoleAlias GetConsoleAliasA
413 #define GetConsoleAliases GetConsoleAliasesA
414 #define GetConsoleAliasesLength GetConsoleAliasesLengthA
415 #define GetConsoleTitle GetConsoleTitleA
416 #define PeekConsoleInput PeekConsoleInputA
417 #define ReadConsole ReadConsoleA
418 #define ReadConsoleInput ReadConsoleInputA
419 #define ReadConsoleOutput ReadConsoleOutputA
420 #define ReadConsoleOutputCharacter ReadConsoleOutputCharacterA
421 #define ScrollConsoleScreenBuffer ScrollConsoleScreenBufferA
422 #define SetConsoleTitle SetConsoleTitleA
423 #define WriteConsole WriteConsoleA
424 #define WriteConsoleInput WriteConsoleInputA
425 #define WriteConsoleOutput WriteConsoleOutputA
426 #define WriteConsoleOutputCharacter WriteConsoleOutputCharacterA
427 #endif
428
429 #ifdef _MSC_VER
430 #pragma warning(pop)
431 #endif
432
433 #ifdef __cplusplus
434 }
435 #endif
436 #endif