PageRenderTime 62ms CodeModel.GetById 7ms app.highlight 49ms RepoModel.GetById 1ms app.codeStats 0ms

/binding/win32/wincon.d

http://github.com/wilkie/djehuty
D | 916 lines | 682 code | 169 blank | 65 comment | 22 complexity | 49e7278f54c65d8be13720ff854da6a3 MD5 | raw file
  1/*
  2 * wincon.d
  3 *
  4 * This module binds WinCon.h to D. The original copyright notice is preserved
  5 * below.
  6 *
  7 * Author: Dave Wilkinson
  8 * Originated: November 25th, 2009
  9 *
 10 */
 11
 12module binding.win32.wincon;
 13
 14import binding.win32.windef;
 15import binding.win32.winnt;
 16import binding.win32.wingdi;
 17import binding.win32.winbase;
 18
 19extern(System):
 20
 21/*++ BUILD Version: 0002    // Increment this if a change has global effects
 22
 23Copyright (c) Microsoft Corporation. All rights reserved.
 24
 25Module Name:
 26
 27    wincon.h
 28
 29Abstract:
 30
 31    This module contains the public data structures, data types,
 32    and procedures exported by the NT console subsystem.
 33
 34Created:
 35
 36    26-Oct-1990
 37
 38Revision History:
 39
 40--*/
 41
 42struct COORD {
 43    SHORT X;
 44    SHORT Y;
 45}
 46
 47alias COORD* PCOORD;
 48
 49struct SMALL_RECT {
 50    SHORT Left;
 51    SHORT Top;
 52    SHORT Right;
 53    SHORT Bottom;
 54}
 55
 56alias SMALL_RECT* PSMALL_RECT;
 57
 58struct KEY_EVENT_RECORD {
 59    BOOL bKeyDown;
 60    WORD wRepeatCount;
 61    WORD wVirtualKeyCode;
 62    WORD wVirtualScanCode;
 63    union _inner_union {
 64        WCHAR UnicodeChar;
 65        CHAR   AsciiChar;
 66    }
 67	_inner_union uChar;
 68    DWORD dwControlKeyState;
 69}
 70
 71alias KEY_EVENT_RECORD* PKEY_EVENT_RECORD;
 72
 73//
 74// ControlKeyState flags
 75//
 76
 77const auto RIGHT_ALT_PRESSED     = 0x0001; // the right alt key is pressed.
 78const auto LEFT_ALT_PRESSED      = 0x0002; // the left alt key is pressed.
 79const auto RIGHT_CTRL_PRESSED    = 0x0004; // the right ctrl key is pressed.
 80const auto LEFT_CTRL_PRESSED     = 0x0008; // the left ctrl key is pressed.
 81const auto SHIFT_PRESSED         = 0x0010; // the shift key is pressed.
 82const auto NUMLOCK_ON            = 0x0020; // the numlock light is on.
 83const auto SCROLLLOCK_ON         = 0x0040; // the scrolllock light is on.
 84const auto CAPSLOCK_ON           = 0x0080; // the capslock light is on.
 85const auto ENHANCED_KEY          = 0x0100; // the key is enhanced.
 86const auto NLS_DBCSCHAR          = 0x00010000; // DBCS for JPN: SBCS/DBCS mode.
 87const auto NLS_ALPHANUMERIC      = 0x00000000; // DBCS for JPN: Alphanumeric mode.
 88const auto NLS_KATAKANA          = 0x00020000; // DBCS for JPN: Katakana mode.
 89const auto NLS_HIRAGANA          = 0x00040000; // DBCS for JPN: Hiragana mode.
 90const auto NLS_ROMAN             = 0x00400000; // DBCS for JPN: Roman/Noroman mode.
 91const auto NLS_IME_CONVERSION    = 0x00800000; // DBCS for JPN: IME conversion.
 92const auto NLS_IME_DISABLE       = 0x20000000; // DBCS for JPN: IME enable/disable.
 93
 94struct MOUSE_EVENT_RECORD {
 95    COORD dwMousePosition;
 96    DWORD dwButtonState;
 97    DWORD dwControlKeyState;
 98    DWORD dwEventFlags;
 99}
100
101alias MOUSE_EVENT_RECORD* PMOUSE_EVENT_RECORD;
102
103//
104// ButtonState flags
105//
106
107const auto FROM_LEFT_1ST_BUTTON_PRESSED    = 0x0001;
108const auto RIGHTMOST_BUTTON_PRESSED        = 0x0002;
109const auto FROM_LEFT_2ND_BUTTON_PRESSED    = 0x0004;
110const auto FROM_LEFT_3RD_BUTTON_PRESSED    = 0x0008;
111const auto FROM_LEFT_4TH_BUTTON_PRESSED    = 0x0010;
112
113//
114// EventFlags
115//
116
117const auto MOUSE_MOVED   = 0x0001;
118const auto DOUBLE_CLICK  = 0x0002;
119const auto MOUSE_WHEELED = 0x0004;
120
121const auto MOUSE_HWHEELED = 0x0008;
122
123struct WINDOW_BUFFER_SIZE_RECORD {
124    COORD dwSize;
125}
126
127alias WINDOW_BUFFER_SIZE_RECORD* PWINDOW_BUFFER_SIZE_RECORD;
128
129struct MENU_EVENT_RECORD {
130    UINT dwCommandId;
131}
132
133alias MENU_EVENT_RECORD* PMENU_EVENT_RECORD;
134
135struct FOCUS_EVENT_RECORD {
136    BOOL bSetFocus;
137}
138
139alias FOCUS_EVENT_RECORD* PFOCUS_EVENT_RECORD;
140
141struct INPUT_RECORD {
142    WORD EventType;
143    union _inner_union {
144        KEY_EVENT_RECORD KeyEvent;
145        MOUSE_EVENT_RECORD MouseEvent;
146        WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
147        MENU_EVENT_RECORD MenuEvent;
148        FOCUS_EVENT_RECORD FocusEvent;
149    }
150	_inner_union Event;
151}
152
153alias INPUT_RECORD* PINPUT_RECORD;
154
155//
156//  EventType flags:
157//
158
159const auto KEY_EVENT         = 0x0001; // Event contains key event record
160const auto MOUSE_EVENT       = 0x0002; // Event contains mouse event record
161const auto WINDOW_BUFFER_SIZE_EVENT = 0x0004; // Event contains window change event record
162const auto MENU_EVENT  = 0x0008; // Event contains menu event record
163const auto FOCUS_EVENT = 0x0010; // event contains focus change
164
165struct CHAR_INFO {
166    union _inner_union {
167        WCHAR UnicodeChar;
168        CHAR   AsciiChar;
169    }
170	_inner_union Char;
171    WORD Attributes;
172}
173
174alias CHAR_INFO* PCHAR_INFO;
175
176//
177// Attributes flags:
178//
179
180const auto FOREGROUND_BLUE      = 0x0001; // text color contains blue.
181const auto FOREGROUND_GREEN     = 0x0002; // text color contains green.
182const auto FOREGROUND_RED       = 0x0004; // text color contains red.
183const auto FOREGROUND_INTENSITY = 0x0008; // text color is intensified.
184const auto BACKGROUND_BLUE      = 0x0010; // background color contains blue.
185const auto BACKGROUND_GREEN     = 0x0020; // background color contains green.
186const auto BACKGROUND_RED       = 0x0040; // background color contains red.
187const auto BACKGROUND_INTENSITY = 0x0080; // background color is intensified.
188const auto COMMON_LVB_LEADING_BYTE    = 0x0100; // Leading Byte of DBCS
189const auto COMMON_LVB_TRAILING_BYTE   = 0x0200; // Trailing Byte of DBCS
190const auto COMMON_LVB_GRID_HORIZONTAL = 0x0400; // DBCS: Grid attribute: top horizontal.
191const auto COMMON_LVB_GRID_LVERTICAL  = 0x0800; // DBCS: Grid attribute: left vertical.
192const auto COMMON_LVB_GRID_RVERTICAL  = 0x1000; // DBCS: Grid attribute: right vertical.
193const auto COMMON_LVB_REVERSE_VIDEO   = 0x4000; // DBCS: Reverse fore/back ground attribute.
194const auto COMMON_LVB_UNDERSCORE      = 0x8000; // DBCS: Underscore.
195
196const auto COMMON_LVB_SBCSDBCS        = 0x0300; // SBCS or DBCS flag.
197
198
199struct CONSOLE_SCREEN_BUFFER_INFO {
200    COORD dwSize;
201    COORD dwCursorPosition;
202    WORD  wAttributes;
203    SMALL_RECT srWindow;
204    COORD dwMaximumWindowSize;
205}
206
207alias CONSOLE_SCREEN_BUFFER_INFO* PCONSOLE_SCREEN_BUFFER_INFO;
208
209struct CONSOLE_SCREEN_BUFFER_INFOEX {
210    ULONG cbSize;
211    COORD dwSize;
212    COORD dwCursorPosition;
213    WORD wAttributes;
214    SMALL_RECT srWindow;
215    COORD dwMaximumWindowSize;
216    WORD wPopupAttributes;
217    BOOL bFullscreenSupported;
218    COLORREF ColorTable[16];
219}
220
221alias CONSOLE_SCREEN_BUFFER_INFOEX* PCONSOLE_SCREEN_BUFFER_INFOEX;
222
223struct CONSOLE_CURSOR_INFO {
224    DWORD  dwSize;
225    BOOL   bVisible;
226}
227
228alias CONSOLE_CURSOR_INFO* PCONSOLE_CURSOR_INFO;
229
230struct CONSOLE_FONT_INFO {
231    DWORD  nFont;
232    COORD  dwFontSize;
233}
234
235alias CONSOLE_FONT_INFO* PCONSOLE_FONT_INFO;
236
237version(NOGDI) {
238}
239else {
240	struct CONSOLE_FONT_INFOEX {
241	    ULONG cbSize;
242	    DWORD nFont;
243	    COORD dwFontSize;
244	    UINT FontFamily;
245	    UINT FontWeight;
246	    WCHAR[LF_FACESIZE] FaceName;
247	}
248
249	alias CONSOLE_FONT_INFOEX* PCONSOLE_FONT_INFOEX;
250}
251
252const auto HISTORY_NO_DUP_FLAG = 0x1;
253
254struct CONSOLE_HISTORY_INFO {
255    UINT cbSize;
256    UINT HistoryBufferSize;
257    UINT NumberOfHistoryBuffers;
258    DWORD dwFlags;
259}
260
261alias CONSOLE_HISTORY_INFO* PCONSOLE_HISTORY_INFO;
262
263struct CONSOLE_SELECTION_INFO {
264    DWORD dwFlags;
265    COORD dwSelectionAnchor;
266    SMALL_RECT srSelection;
267}
268
269alias CONSOLE_SELECTION_INFO* PCONSOLE_SELECTION_INFO;
270
271//
272// Selection flags
273//
274
275const auto CONSOLE_NO_SELECTION            = 0x0000;
276const auto CONSOLE_SELECTION_IN_PROGRESS   = 0x0001;   // selection has begun
277const auto CONSOLE_SELECTION_NOT_EMPTY     = 0x0002;   // non-null select rectangle
278const auto CONSOLE_MOUSE_SELECTION         = 0x0004;   // selecting with mouse
279const auto CONSOLE_MOUSE_DOWN              = 0x0008;   // mouse is down
280
281//
282// alias for ctrl-c handler routines
283//
284
285alias BOOL function(DWORD CtrlType) PHANDLER_ROUTINE;
286
287const auto CTRL_C_EVENT        = 0;
288const auto CTRL_BREAK_EVENT    = 1;
289const auto CTRL_CLOSE_EVENT    = 2;
290// 3 is reserved!
291// 4 is reserved!
292const auto CTRL_LOGOFF_EVENT   = 5;
293const auto CTRL_SHUTDOWN_EVENT = 6;
294
295//
296//  Input Mode flags:
297//
298
299const auto ENABLE_PROCESSED_INPUT  = 0x0001;
300const auto ENABLE_LINE_INPUT       = 0x0002;
301const auto ENABLE_ECHO_INPUT       = 0x0004;
302const auto ENABLE_WINDOW_INPUT     = 0x0008;
303const auto ENABLE_MOUSE_INPUT      = 0x0010;
304const auto ENABLE_INSERT_MODE      = 0x0020;
305const auto ENABLE_QUICK_EDIT_MODE  = 0x0040;
306const auto ENABLE_EXTENDED_FLAGS   = 0x0080;
307const auto ENABLE_AUTO_POSITION    = 0x0100;
308
309//
310// Output Mode flags:
311//
312
313const auto ENABLE_PROCESSED_OUTPUT    = 0x0001;
314const auto ENABLE_WRAP_AT_EOL_OUTPUT  = 0x0002;
315
316//
317// direct API definitions.
318//
319
320BOOL PeekConsoleInputA(
321    HANDLE hConsoleInput,
322    PINPUT_RECORD lpBuffer,
323    DWORD nLength,
324    LPDWORD lpNumberOfEventsRead
325    );
326
327BOOL PeekConsoleInputW(
328    HANDLE hConsoleInput,
329    PINPUT_RECORD lpBuffer,
330    DWORD nLength,
331    LPDWORD lpNumberOfEventsRead
332    );
333
334version(UNICODE) {
335	alias PeekConsoleInputW PeekConsoleInput;
336}
337else {
338	alias PeekConsoleInputA PeekConsoleInput;
339}
340
341BOOL ReadConsoleInputA(
342    HANDLE hConsoleInput,
343    PINPUT_RECORD lpBuffer,
344    DWORD nLength,
345    LPDWORD lpNumberOfEventsRead
346    );
347
348BOOL ReadConsoleInputW(
349    HANDLE hConsoleInput,
350    PINPUT_RECORD lpBuffer,
351    DWORD nLength,
352    LPDWORD lpNumberOfEventsRead
353    );
354
355version(UNICODE) {
356	alias ReadConsoleInputW ReadConsoleInput;
357}
358else {
359	alias ReadConsoleInputA ReadConsoleInput;
360}
361
362BOOL WriteConsoleInputA(
363    HANDLE hConsoleInput,
364    INPUT_RECORD *lpBuffer,
365    DWORD nLength,
366    LPDWORD lpNumberOfEventsWritten
367    );
368
369BOOL WriteConsoleInputW(
370    HANDLE hConsoleInput,
371    INPUT_RECORD *lpBuffer,
372    DWORD nLength,
373    LPDWORD lpNumberOfEventsWritten
374    );
375
376version(UNICODE) {
377	alias WriteConsoleInputW WriteConsoleInput;
378}
379else {
380	alias WriteConsoleInputA WriteConsoleInput;
381}
382
383BOOL ReadConsoleOutputA(
384    HANDLE hConsoleOutput,
385    PCHAR_INFO lpBuffer,
386    COORD dwBufferSize,
387    COORD dwBufferCoord,
388    PSMALL_RECT lpReadRegion
389    );
390
391BOOL ReadConsoleOutputW(
392    HANDLE hConsoleOutput,
393    PCHAR_INFO lpBuffer,
394    COORD dwBufferSize,
395    COORD dwBufferCoord,
396    PSMALL_RECT lpReadRegion
397    );
398
399version(UNICODE) {
400	alias ReadConsoleOutputW ReadConsoleOutput;
401}
402else {
403	alias ReadConsoleOutputA ReadConsoleOutput;
404}
405
406BOOL WriteConsoleOutputA(
407    HANDLE hConsoleOutput,
408    CHAR_INFO *lpBuffer,
409    COORD dwBufferSize,
410    COORD dwBufferCoord,
411    PSMALL_RECT lpWriteRegion
412    );
413
414BOOL WriteConsoleOutputW(
415    HANDLE hConsoleOutput,
416    CHAR_INFO *lpBuffer,
417    COORD dwBufferSize,
418    COORD dwBufferCoord,
419    PSMALL_RECT lpWriteRegion
420    );
421
422version(UNICODE) {
423	alias WriteConsoleOutputW WriteConsoleOutput;
424}
425else {
426	alias WriteConsoleOutputA WriteConsoleOutput;
427}
428
429BOOL ReadConsoleOutputCharacterA(
430    HANDLE hConsoleOutput,
431    LPSTR lpCharacter,
432    DWORD nLength,
433    COORD dwReadCoord,
434    LPDWORD lpNumberOfCharsRead
435    );
436
437BOOL ReadConsoleOutputCharacterW(
438    HANDLE hConsoleOutput,
439    LPWSTR lpCharacter,
440    DWORD nLength,
441    COORD dwReadCoord,
442    LPDWORD lpNumberOfCharsRead
443    );
444
445version(UNICODE) {
446	alias ReadConsoleOutputCharacterW ReadConsoleOutputCharacter;
447}
448else {
449	alias ReadConsoleOutputCharacterA ReadConsoleOutputCharacter;
450}
451
452BOOL ReadConsoleOutputAttribute(
453    HANDLE hConsoleOutput,
454    LPWORD lpAttribute,
455    DWORD nLength,
456    COORD dwReadCoord,
457	LPDWORD lpNumberOfAttrsRead
458    );
459
460BOOL WriteConsoleOutputCharacterA(
461    HANDLE hConsoleOutput,
462    LPCSTR lpCharacter,
463    DWORD nLength,
464    COORD dwWriteCoord,
465    LPDWORD lpNumberOfCharsWritten
466    );
467
468BOOL WriteConsoleOutputCharacterW(
469    HANDLE hConsoleOutput,
470    LPCWSTR lpCharacter,
471    DWORD nLength,
472    COORD dwWriteCoord,
473    LPDWORD lpNumberOfCharsWritten
474    );
475
476version(UNICODE) {
477	alias WriteConsoleOutputCharacterW WriteConsoleOutputCharacter;
478}
479else {
480	alias WriteConsoleOutputCharacterA WriteConsoleOutputCharacter;
481}
482
483BOOL WriteConsoleOutputAttribute(
484    HANDLE hConsoleOutput,
485    WORD *lpAttribute,
486    DWORD nLength,
487    COORD dwWriteCoord,
488    LPDWORD lpNumberOfAttrsWritten
489    );
490
491BOOL FillConsoleOutputCharacterA(
492    HANDLE hConsoleOutput,
493    CHAR  cCharacter,
494    DWORD  nLength,
495    COORD  dwWriteCoord,
496    LPDWORD lpNumberOfCharsWritten
497    );
498
499BOOL FillConsoleOutputCharacterW(
500    HANDLE hConsoleOutput,
501    WCHAR  cCharacter,
502    DWORD  nLength,
503    COORD  dwWriteCoord,
504    LPDWORD lpNumberOfCharsWritten
505    );
506
507version(UNICODE) {
508	alias FillConsoleOutputCharacterW FillConsoleOutputCharacter;
509}
510else {
511	alias FillConsoleOutputCharacterA FillConsoleOutputCharacter;
512}
513
514BOOL FillConsoleOutputAttribute(
515    HANDLE hConsoleOutput,
516    WORD   wAttribute,
517    DWORD  nLength,
518    COORD  dwWriteCoord,
519    LPDWORD lpNumberOfAttrsWritten
520    );
521
522BOOL GetConsoleMode(
523    HANDLE hConsoleHandle,
524    LPDWORD lpMode
525    );
526
527BOOL GetNumberOfConsoleInputEvents(
528    HANDLE hConsoleInput,
529    LPDWORD lpNumberOfEvents
530    );
531
532const HANDLE CONSOLE_REAL_OUTPUT_HANDLE = (cast(HANDLE)(-2));
533const HANDLE CONSOLE_REAL_INPUT_HANDLE = (cast(HANDLE)(-3));
534
535BOOL GetConsoleScreenBufferInfo(
536    HANDLE hConsoleOutput,
537    PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
538    );
539
540BOOL GetConsoleScreenBufferInfoEx(
541    HANDLE hConsoleOutput,
542    PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
543
544BOOL SetConsoleScreenBufferInfoEx(
545    HANDLE hConsoleOutput,
546    PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
547
548COORD GetLargestConsoleWindowSize(
549    HANDLE hConsoleOutput
550    );
551
552BOOL GetConsoleCursorInfo(
553    HANDLE hConsoleOutput,
554    PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
555    );
556
557BOOL GetCurrentConsoleFont(
558    HANDLE hConsoleOutput,
559    BOOL bMaximumWindow,
560    PCONSOLE_FONT_INFO lpConsoleCurrentFont
561    );
562
563version(NOGDI) {
564}
565else {
566	BOOL GetCurrentConsoleFontEx(
567	    HANDLE hConsoleOutput,
568	    BOOL bMaximumWindow,
569	    PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
570
571	BOOL SetCurrentConsoleFontEx(
572	    HANDLE hConsoleOutput,
573	    BOOL bMaximumWindow,
574	    PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
575}
576
577BOOL GetConsoleHistoryInfo(
578    PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo);
579
580BOOL SetConsoleHistoryInfo(
581    PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo);
582
583COORD GetConsoleFontSize(
584    HANDLE hConsoleOutput,
585    DWORD nFont
586    );
587
588BOOL GetConsoleSelectionInfo(
589    PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo
590    );
591
592BOOL GetNumberOfConsoleMouseButtons(
593    LPDWORD lpNumberOfMouseButtons
594    );
595
596BOOL SetConsoleMode(
597    HANDLE hConsoleHandle,
598    DWORD dwMode
599    );
600
601BOOL SetConsoleActiveScreenBuffer(
602    HANDLE hConsoleOutput
603    );
604
605BOOL FlushConsoleInputBuffer(
606    HANDLE hConsoleInput
607    );
608
609BOOL SetConsoleScreenBufferSize(
610    HANDLE hConsoleOutput,
611    COORD dwSize
612    );
613
614BOOL SetConsoleCursorPosition(
615    HANDLE hConsoleOutput,
616    COORD dwCursorPosition
617    );
618
619BOOL SetConsoleCursorInfo(
620    HANDLE hConsoleOutput,
621    CONSOLE_CURSOR_INFO *lpConsoleCursorInfo
622    );
623
624BOOL ScrollConsoleScreenBufferA(
625    HANDLE hConsoleOutput,
626    SMALL_RECT *lpScrollRectangle,
627    SMALL_RECT *lpClipRectangle,
628    COORD dwDestinationOrigin,
629    CHAR_INFO *lpFill
630    );
631
632BOOL ScrollConsoleScreenBufferW(
633    HANDLE hConsoleOutput,
634    SMALL_RECT *lpScrollRectangle,
635    SMALL_RECT *lpClipRectangle,
636    COORD dwDestinationOrigin,
637    CHAR_INFO *lpFill
638    );
639
640version(UNICODE) {
641	alias ScrollConsoleScreenBufferW ScrollConsoleScreenBuffer;
642}
643else {
644	alias ScrollConsoleScreenBufferA ScrollConsoleScreenBuffer;
645}
646
647BOOL SetConsoleWindowInfo(
648    HANDLE hConsoleOutput,
649    BOOL bAbsolute,
650    SMALL_RECT *lpConsoleWindow
651    );
652
653BOOL SetConsoleTextAttribute(
654    HANDLE hConsoleOutput,
655    WORD wAttributes
656    );
657
658BOOL SetConsoleCtrlHandler(
659    PHANDLER_ROUTINE HandlerRoutine,
660    BOOL Add);
661
662BOOL GenerateConsoleCtrlEvent(
663    DWORD dwCtrlEvent,
664    DWORD dwProcessGroupId
665    );
666
667BOOL AllocConsole();
668
669BOOL FreeConsole();
670
671BOOL AttachConsole(
672    DWORD dwProcessId
673    );
674
675const auto ATTACH_PARENT_PROCESS = (cast(DWORD)-1);
676
677DWORD GetConsoleTitleA(
678    LPSTR lpConsoleTitle,
679    DWORD nSize
680    );
681
682
683DWORD GetConsoleTitleW(
684    LPWSTR lpConsoleTitle,
685    DWORD nSize
686    );
687
688version(UNICODE) {
689	alias GetConsoleTitleW GetConsoleTitle;
690}
691else {
692	alias GetConsoleTitleA GetConsoleTitle;
693}
694
695DWORD GetConsoleOriginalTitleA(
696    LPSTR lpConsoleTitle,
697    DWORD nSize);
698
699DWORD GetConsoleOriginalTitleW(
700    LPWSTR lpConsoleTitle,
701    DWORD nSize);
702
703version(UNICODE) {
704	alias GetConsoleOriginalTitleW GetConsoleOriginalTitle;
705}
706else {
707	alias GetConsoleOriginalTitleA GetConsoleOriginalTitle;
708}
709
710BOOL SetConsoleTitleA(
711    LPCSTR lpConsoleTitle
712    );
713
714BOOL SetConsoleTitleW(
715    LPCWSTR lpConsoleTitle
716    );
717
718version(UNICODE) {
719	alias SetConsoleTitleW SetConsoleTitle;
720}
721else {
722	alias SetConsoleTitleA SetConsoleTitle;
723}
724
725struct CONSOLE_READCONSOLE_CONTROL {
726    ULONG nLength;           // sizeof( CONSOLE_READCONSOLE_CONTROL )
727    ULONG nInitialChars;
728    ULONG dwCtrlWakeupMask;
729    ULONG dwControlKeyState;
730}
731
732alias CONSOLE_READCONSOLE_CONTROL* PCONSOLE_READCONSOLE_CONTROL;
733
734BOOL ReadConsoleA(
735    HANDLE hConsoleInput,
736	LPVOID lpBuffer,
737    DWORD nNumberOfCharsToRead,
738    LPDWORD lpNumberOfCharsRead,
739    PCONSOLE_READCONSOLE_CONTROL pInputControl
740    );
741
742BOOL ReadConsoleW(
743    HANDLE hConsoleInput,
744	LPVOID lpBuffer,
745    DWORD nNumberOfCharsToRead,
746    LPDWORD lpNumberOfCharsRead,
747    PCONSOLE_READCONSOLE_CONTROL pInputControl
748    );
749
750version(UNICODE) {
751	alias ReadConsoleW ReadConsole;
752}
753else {
754	alias ReadConsoleA ReadConsole;
755}
756
757BOOL WriteConsoleA(
758    HANDLE hConsoleOutput,
759    VOID *lpBuffer,
760    DWORD nNumberOfCharsToWrite,
761    LPDWORD lpNumberOfCharsWritten,
762    LPVOID lpReserved
763    );
764
765BOOL WriteConsoleW(
766    HANDLE hConsoleOutput,
767    VOID *lpBuffer,
768    DWORD nNumberOfCharsToWrite,
769    LPDWORD lpNumberOfCharsWritten,
770    LPVOID lpReserved
771    );
772
773version(UNICODE) {
774	alias WriteConsoleW WriteConsole;
775}
776else {
777	alias WriteConsoleA WriteConsole;
778}
779
780const auto CONSOLE_TEXTMODE_BUFFER  = 1;
781
782HANDLE CreateConsoleScreenBuffer(
783    DWORD dwDesiredAccess,
784    DWORD dwShareMode,
785    SECURITY_ATTRIBUTES *lpSecurityAttributes,
786    DWORD dwFlags,
787    LPVOID lpScreenBufferData
788    );
789
790UINT GetConsoleCP();
791
792BOOL SetConsoleCP(
793    UINT wCodePageID
794    );
795
796UINT GetConsoleOutputCP();
797
798BOOL SetConsoleOutputCP(
799    UINT wCodePageID
800    );
801
802const auto CONSOLE_FULLSCREEN = 1;            // fullscreen console
803const auto CONSOLE_FULLSCREEN_HARDWARE = 2;   // console owns the hardware
804
805BOOL GetConsoleDisplayMode(
806    LPDWORD lpModeFlags);
807
808const auto CONSOLE_FULLSCREEN_MODE = 1;
809const auto CONSOLE_WINDOWED_MODE = 2;
810
811BOOL SetConsoleDisplayMode(
812    HANDLE hConsoleOutput,
813    DWORD dwFlags,
814    PCOORD lpNewScreenBufferDimensions);
815
816HWND GetConsoleWindow();
817
818DWORD GetConsoleProcessList(
819    LPDWORD lpdwProcessList,
820    DWORD dwProcessCount);
821
822//
823// Aliasing apis.
824//
825
826BOOL AddConsoleAliasA(
827    LPSTR Source,
828    LPSTR Target,
829    LPSTR ExeName);
830
831BOOL AddConsoleAliasW(
832    LPWSTR Source,
833    LPWSTR Target,
834    LPWSTR ExeName);
835
836version(UNICODE) {
837	alias AddConsoleAliasW AddConsoleAlias;
838}
839else {
840	alias AddConsoleAliasA AddConsoleAlias;
841}
842
843DWORD GetConsoleAliasA(
844    LPSTR Source,
845    LPSTR TargetBuffer,
846    DWORD TargetBufferLength,
847    LPSTR ExeName);
848
849DWORD GetConsoleAliasW(
850    LPWSTR Source,
851    LPWSTR TargetBuffer,
852    DWORD TargetBufferLength,
853    LPWSTR ExeName);
854
855version(UNICODE) {
856	alias GetConsoleAliasW GetConsoleAlias;
857}
858else {
859	alias GetConsoleAliasA GetConsoleAlias;
860}
861
862DWORD GetConsoleAliasesLengthA(
863    LPSTR ExeName);
864
865DWORD GetConsoleAliasesLengthW(
866    LPWSTR ExeName);
867
868version(UNICODE) {
869	alias GetConsoleAliasesLengthW GetConsoleAliasesLength;
870}
871else {
872	alias GetConsoleAliasesLengthA GetConsoleAliasesLength;
873}
874
875DWORD GetConsoleAliasExesLengthA();
876
877DWORD GetConsoleAliasExesLengthW();
878
879version(UNICODE) {
880	alias GetConsoleAliasExesLengthW GetConsoleAliasExesLength;
881}
882else {
883	alias GetConsoleAliasExesLengthA GetConsoleAliasExesLength;
884}
885
886DWORD GetConsoleAliasesA(
887    LPSTR AliasBuffer,
888    DWORD AliasBufferLength,
889    LPSTR ExeName);
890
891DWORD GetConsoleAliasesW(
892	LPWSTR AliasBuffer,
893    DWORD AliasBufferLength,
894    LPWSTR ExeName);
895
896version(UNICODE) {
897	alias GetConsoleAliasesW GetConsoleAliases;
898}
899else {
900	alias GetConsoleAliasesA GetConsoleAliases;
901}
902
903DWORD GetConsoleAliasExesA(
904    LPSTR ExeNameBuffer,
905    DWORD ExeNameBufferLength);
906
907DWORD GetConsoleAliasExesW(
908    LPWSTR ExeNameBuffer,
909    DWORD ExeNameBufferLength);
910
911version(UNICODE) {
912	alias GetConsoleAliasExesW GetConsoleAliasExes;
913}
914else {
915	alias GetConsoleAliasExesA GetConsoleAliasExes;
916}