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