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