wincon.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the w64 mingw-runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER within this package.
  5. */
  6. #ifndef _WINCON_
  7. #define _WINCON_
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. typedef struct _COORD {
  12. SHORT X;
  13. SHORT Y;
  14. } COORD,*PCOORD;
  15. typedef struct _SMALL_RECT {
  16. SHORT Left;
  17. SHORT Top;
  18. SHORT Right;
  19. SHORT Bottom;
  20. } SMALL_RECT,*PSMALL_RECT;
  21. typedef struct _KEY_EVENT_RECORD {
  22. WINBOOL bKeyDown;
  23. WORD wRepeatCount;
  24. WORD wVirtualKeyCode;
  25. WORD wVirtualScanCode;
  26. union {
  27. WCHAR UnicodeChar;
  28. CHAR AsciiChar;
  29. } uChar;
  30. DWORD dwControlKeyState;
  31. } KEY_EVENT_RECORD,*PKEY_EVENT_RECORD;
  32. #define RIGHT_ALT_PRESSED 0x1
  33. #define LEFT_ALT_PRESSED 0x2
  34. #define RIGHT_CTRL_PRESSED 0x4
  35. #define LEFT_CTRL_PRESSED 0x8
  36. #define SHIFT_PRESSED 0x10
  37. #define NUMLOCK_ON 0x20
  38. #define SCROLLLOCK_ON 0x40
  39. #define CAPSLOCK_ON 0x80
  40. #define ENHANCED_KEY 0x100
  41. #define NLS_DBCSCHAR 0x10000
  42. #define NLS_ALPHANUMERIC 0x0
  43. #define NLS_KATAKANA 0x20000
  44. #define NLS_HIRAGANA 0x40000
  45. #define NLS_ROMAN 0x400000
  46. #define NLS_IME_CONVERSION 0x800000
  47. #define NLS_IME_DISABLE 0x20000000
  48. typedef struct _MOUSE_EVENT_RECORD {
  49. COORD dwMousePosition;
  50. DWORD dwButtonState;
  51. DWORD dwControlKeyState;
  52. DWORD dwEventFlags;
  53. } MOUSE_EVENT_RECORD,*PMOUSE_EVENT_RECORD;
  54. #define FROM_LEFT_1ST_BUTTON_PRESSED 0x1
  55. #define RIGHTMOST_BUTTON_PRESSED 0x2
  56. #define FROM_LEFT_2ND_BUTTON_PRESSED 0x4
  57. #define FROM_LEFT_3RD_BUTTON_PRESSED 0x8
  58. #define FROM_LEFT_4TH_BUTTON_PRESSED 0x10
  59. #define MOUSE_MOVED 0x1
  60. #define DOUBLE_CLICK 0x2
  61. #define MOUSE_WHEELED 0x4
  62. typedef struct _WINDOW_BUFFER_SIZE_RECORD {
  63. COORD dwSize;
  64. } WINDOW_BUFFER_SIZE_RECORD,*PWINDOW_BUFFER_SIZE_RECORD;
  65. typedef struct _MENU_EVENT_RECORD {
  66. UINT dwCommandId;
  67. } MENU_EVENT_RECORD,*PMENU_EVENT_RECORD;
  68. typedef struct _FOCUS_EVENT_RECORD {
  69. WINBOOL bSetFocus;
  70. } FOCUS_EVENT_RECORD,*PFOCUS_EVENT_RECORD;
  71. typedef struct _INPUT_RECORD {
  72. WORD EventType;
  73. union {
  74. KEY_EVENT_RECORD KeyEvent;
  75. MOUSE_EVENT_RECORD MouseEvent;
  76. WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
  77. MENU_EVENT_RECORD MenuEvent;
  78. FOCUS_EVENT_RECORD FocusEvent;
  79. } Event;
  80. } INPUT_RECORD,*PINPUT_RECORD;
  81. #define KEY_EVENT 0x1
  82. #define MOUSE_EVENT 0x2
  83. #define WINDOW_BUFFER_SIZE_EVENT 0x4
  84. #define MENU_EVENT 0x8
  85. #define FOCUS_EVENT 0x10
  86. typedef struct _CHAR_INFO {
  87. union {
  88. WCHAR UnicodeChar;
  89. CHAR AsciiChar;
  90. } Char;
  91. WORD Attributes;
  92. } CHAR_INFO,*PCHAR_INFO;
  93. #define FOREGROUND_BLUE 0x1
  94. #define FOREGROUND_GREEN 0x2
  95. #define FOREGROUND_RED 0x4
  96. #define FOREGROUND_INTENSITY 0x8
  97. #define BACKGROUND_BLUE 0x10
  98. #define BACKGROUND_GREEN 0x20
  99. #define BACKGROUND_RED 0x40
  100. #define BACKGROUND_INTENSITY 0x80
  101. #define COMMON_LVB_LEADING_BYTE 0x100
  102. #define COMMON_LVB_TRAILING_BYTE 0x200
  103. #define COMMON_LVB_GRID_HORIZONTAL 0x400
  104. #define COMMON_LVB_GRID_LVERTICAL 0x800
  105. #define COMMON_LVB_GRID_RVERTICAL 0x1000
  106. #define COMMON_LVB_REVERSE_VIDEO 0x4000
  107. #define COMMON_LVB_UNDERSCORE 0x8000
  108. #define COMMON_LVB_SBCSDBCS 0x300
  109. typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
  110. COORD dwSize;
  111. COORD dwCursorPosition;
  112. WORD wAttributes;
  113. SMALL_RECT srWindow;
  114. COORD dwMaximumWindowSize;
  115. } CONSOLE_SCREEN_BUFFER_INFO,*PCONSOLE_SCREEN_BUFFER_INFO;
  116. typedef struct _CONSOLE_CURSOR_INFO {
  117. DWORD dwSize;
  118. WINBOOL bVisible;
  119. } CONSOLE_CURSOR_INFO,*PCONSOLE_CURSOR_INFO;
  120. typedef struct _CONSOLE_FONT_INFO {
  121. DWORD nFont;
  122. COORD dwFontSize;
  123. } CONSOLE_FONT_INFO,*PCONSOLE_FONT_INFO;
  124. typedef struct _CONSOLE_SELECTION_INFO {
  125. DWORD dwFlags;
  126. COORD dwSelectionAnchor;
  127. SMALL_RECT srSelection;
  128. } CONSOLE_SELECTION_INFO,*PCONSOLE_SELECTION_INFO;
  129. #define CONSOLE_NO_SELECTION 0x0
  130. #define CONSOLE_SELECTION_IN_PROGRESS 0x1
  131. #define CONSOLE_SELECTION_NOT_EMPTY 0x2
  132. #define CONSOLE_MOUSE_SELECTION 0x4
  133. #define CONSOLE_MOUSE_DOWN 0x8
  134. typedef WINBOOL (WINAPI *PHANDLER_ROUTINE)(DWORD CtrlType);
  135. #define CTRL_C_EVENT 0
  136. #define CTRL_BREAK_EVENT 1
  137. #define CTRL_CLOSE_EVENT 2
  138. #define CTRL_LOGOFF_EVENT 5
  139. #define CTRL_SHUTDOWN_EVENT 6
  140. #define ENABLE_PROCESSED_INPUT 0x1
  141. #define ENABLE_LINE_INPUT 0x2
  142. #define ENABLE_ECHO_INPUT 0x4
  143. #define ENABLE_WINDOW_INPUT 0x8
  144. #define ENABLE_MOUSE_INPUT 0x10
  145. #define ENABLE_PROCESSED_OUTPUT 0x1
  146. #define ENABLE_WRAP_AT_EOL_OUTPUT 0x2
  147. #ifdef UNICODE
  148. #define PeekConsoleInput PeekConsoleInputW
  149. #define ReadConsoleInput ReadConsoleInputW
  150. #define WriteConsoleInput WriteConsoleInputW
  151. #define ReadConsoleOutput ReadConsoleOutputW
  152. #define WriteConsoleOutput WriteConsoleOutputW
  153. #define ReadConsoleOutputCharacter ReadConsoleOutputCharacterW
  154. #define WriteConsoleOutputCharacter WriteConsoleOutputCharacterW
  155. #define FillConsoleOutputCharacter FillConsoleOutputCharacterW
  156. #define ScrollConsoleScreenBuffer ScrollConsoleScreenBufferW
  157. #define GetConsoleTitle GetConsoleTitleW
  158. #define SetConsoleTitle SetConsoleTitleW
  159. #define ReadConsole ReadConsoleW
  160. #define WriteConsole WriteConsoleW
  161. #define AddConsoleAlias AddConsoleAliasW
  162. #define GetConsoleAlias GetConsoleAliasW
  163. #define GetConsoleAliasesLength GetConsoleAliasesLengthW
  164. #define GetConsoleAliasExesLength GetConsoleAliasExesLengthW
  165. #define GetConsoleAliases GetConsoleAliasesW
  166. #define GetConsoleAliasExes GetConsoleAliasExesW
  167. #else
  168. #define PeekConsoleInput PeekConsoleInputA
  169. #define ReadConsoleInput ReadConsoleInputA
  170. #define WriteConsoleInput WriteConsoleInputA
  171. #define ReadConsoleOutput ReadConsoleOutputA
  172. #define WriteConsoleOutput WriteConsoleOutputA
  173. #define ReadConsoleOutputCharacter ReadConsoleOutputCharacterA
  174. #define WriteConsoleOutputCharacter WriteConsoleOutputCharacterA
  175. #define FillConsoleOutputCharacter FillConsoleOutputCharacterA
  176. #define ScrollConsoleScreenBuffer ScrollConsoleScreenBufferA
  177. #define GetConsoleTitle GetConsoleTitleA
  178. #define SetConsoleTitle SetConsoleTitleA
  179. #define ReadConsole ReadConsoleA
  180. #define WriteConsole WriteConsoleA
  181. #define AddConsoleAlias AddConsoleAliasA
  182. #define GetConsoleAlias GetConsoleAliasA
  183. #define GetConsoleAliasesLength GetConsoleAliasesLengthA
  184. #define GetConsoleAliasExesLength GetConsoleAliasExesLengthA
  185. #define GetConsoleAliases GetConsoleAliasesA
  186. #define GetConsoleAliasExes GetConsoleAliasExesA
  187. #endif
  188. WINBASEAPI WINBOOL WINAPI PeekConsoleInputA(HANDLE hConsoleInput,PINPUT_RECORD lpBuffer,DWORD nLength,LPDWORD lpNumberOfEventsRead);
  189. WINBASEAPI WINBOOL WINAPI PeekConsoleInputW(HANDLE hConsoleInput,PINPUT_RECORD lpBuffer,DWORD nLength,LPDWORD lpNumberOfEventsRead);
  190. WINBASEAPI WINBOOL WINAPI ReadConsoleInputA(HANDLE hConsoleInput,PINPUT_RECORD lpBuffer,DWORD nLength,LPDWORD lpNumberOfEventsRead);
  191. WINBASEAPI WINBOOL WINAPI ReadConsoleInputW(HANDLE hConsoleInput,PINPUT_RECORD lpBuffer,DWORD nLength,LPDWORD lpNumberOfEventsRead);
  192. WINBASEAPI WINBOOL WINAPI WriteConsoleInputA(HANDLE hConsoleInput,CONST INPUT_RECORD *lpBuffer,DWORD nLength,LPDWORD lpNumberOfEventsWritten);
  193. WINBASEAPI WINBOOL WINAPI WriteConsoleInputW(HANDLE hConsoleInput,CONST INPUT_RECORD *lpBuffer,DWORD nLength,LPDWORD lpNumberOfEventsWritten);
  194. WINBASEAPI WINBOOL WINAPI ReadConsoleOutputA(HANDLE hConsoleOutput,PCHAR_INFO lpBuffer,COORD dwBufferSize,COORD dwBufferCoord,PSMALL_RECT lpReadRegion);
  195. WINBASEAPI WINBOOL WINAPI ReadConsoleOutputW(HANDLE hConsoleOutput,PCHAR_INFO lpBuffer,COORD dwBufferSize,COORD dwBufferCoord,PSMALL_RECT lpReadRegion);
  196. WINBASEAPI WINBOOL WINAPI WriteConsoleOutputA(HANDLE hConsoleOutput,CONST CHAR_INFO *lpBuffer,COORD dwBufferSize,COORD dwBufferCoord,PSMALL_RECT lpWriteRegion);
  197. WINBASEAPI WINBOOL WINAPI WriteConsoleOutputW(HANDLE hConsoleOutput,CONST CHAR_INFO *lpBuffer,COORD dwBufferSize,COORD dwBufferCoord,PSMALL_RECT lpWriteRegion);
  198. WINBASEAPI WINBOOL WINAPI ReadConsoleOutputCharacterA(HANDLE hConsoleOutput,LPSTR lpCharacter,DWORD nLength,COORD dwReadCoord,LPDWORD lpNumberOfCharsRead);
  199. WINBASEAPI WINBOOL WINAPI ReadConsoleOutputCharacterW(HANDLE hConsoleOutput,LPWSTR lpCharacter,DWORD nLength,COORD dwReadCoord,LPDWORD lpNumberOfCharsRead);
  200. WINBASEAPI WINBOOL WINAPI ReadConsoleOutputAttribute(HANDLE hConsoleOutput,LPWORD lpAttribute,DWORD nLength,COORD dwReadCoord,LPDWORD lpNumberOfAttrsRead);
  201. WINBASEAPI WINBOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput,LPCSTR lpCharacter,DWORD nLength,COORD dwWriteCoord,LPDWORD lpNumberOfCharsWritten);
  202. WINBASEAPI WINBOOL WINAPI WriteConsoleOutputCharacterW(HANDLE hConsoleOutput,LPCWSTR lpCharacter,DWORD nLength,COORD dwWriteCoord,LPDWORD lpNumberOfCharsWritten);
  203. WINBASEAPI WINBOOL WINAPI WriteConsoleOutputAttribute(HANDLE hConsoleOutput,CONST WORD *lpAttribute,DWORD nLength,COORD dwWriteCoord,LPDWORD lpNumberOfAttrsWritten);
  204. WINBASEAPI WINBOOL WINAPI FillConsoleOutputCharacterA(HANDLE hConsoleOutput,CHAR cCharacter,DWORD nLength,COORD dwWriteCoord,LPDWORD lpNumberOfCharsWritten);
  205. WINBASEAPI WINBOOL WINAPI FillConsoleOutputCharacterW(HANDLE hConsoleOutput,WCHAR cCharacter,DWORD nLength,COORD dwWriteCoord,LPDWORD lpNumberOfCharsWritten);
  206. WINBASEAPI WINBOOL WINAPI FillConsoleOutputAttribute(HANDLE hConsoleOutput,WORD wAttribute,DWORD nLength,COORD dwWriteCoord,LPDWORD lpNumberOfAttrsWritten);
  207. WINBASEAPI WINBOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle,LPDWORD lpMode);
  208. WINBASEAPI WINBOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE hConsoleInput,LPDWORD lpNumberOfEvents);
  209. WINBASEAPI WINBOOL WINAPI GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
  210. WINBASEAPI COORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput);
  211. WINBASEAPI WINBOOL WINAPI GetConsoleCursorInfo(HANDLE hConsoleOutput,PCONSOLE_CURSOR_INFO lpConsoleCursorInfo);
  212. WINBASEAPI WINBOOL WINAPI GetCurrentConsoleFont(HANDLE hConsoleOutput,WINBOOL bMaximumWindow,PCONSOLE_FONT_INFO lpConsoleCurrentFont);
  213. WINBASEAPI COORD WINAPI GetConsoleFontSize(HANDLE hConsoleOutput,DWORD nFont);
  214. WINBASEAPI WINBOOL WINAPI GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo);
  215. WINBASEAPI WINBOOL WINAPI GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons);
  216. WINBASEAPI WINBOOL WINAPI SetConsoleMode(HANDLE hConsoleHandle,DWORD dwMode);
  217. WINBASEAPI WINBOOL WINAPI SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput);
  218. WINBASEAPI WINBOOL WINAPI FlushConsoleInputBuffer(HANDLE hConsoleInput);
  219. WINBASEAPI WINBOOL WINAPI SetConsoleScreenBufferSize(HANDLE hConsoleOutput,COORD dwSize);
  220. WINBASEAPI WINBOOL WINAPI SetConsoleCursorPosition(HANDLE hConsoleOutput,COORD dwCursorPosition);
  221. WINBASEAPI WINBOOL WINAPI SetConsoleCursorInfo(HANDLE hConsoleOutput,CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo);
  222. WINBASEAPI WINBOOL WINAPI ScrollConsoleScreenBufferA(HANDLE hConsoleOutput,CONST SMALL_RECT *lpScrollRectangle,CONST SMALL_RECT *lpClipRectangle,COORD dwDestinationOrigin,CONST CHAR_INFO *lpFill);
  223. WINBASEAPI WINBOOL WINAPI ScrollConsoleScreenBufferW(HANDLE hConsoleOutput,CONST SMALL_RECT *lpScrollRectangle,CONST SMALL_RECT *lpClipRectangle,COORD dwDestinationOrigin,CONST CHAR_INFO *lpFill);
  224. WINBASEAPI WINBOOL WINAPI SetConsoleWindowInfo(HANDLE hConsoleOutput,WINBOOL bAbsolute,CONST SMALL_RECT *lpConsoleWindow);
  225. WINBASEAPI WINBOOL WINAPI SetConsoleTextAttribute(HANDLE hConsoleOutput,WORD wAttributes);
  226. WINBASEAPI WINBOOL WINAPI SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine,WINBOOL Add);
  227. WINBASEAPI WINBOOL WINAPI GenerateConsoleCtrlEvent(DWORD dwCtrlEvent,DWORD dwProcessGroupId);
  228. WINBASEAPI WINBOOL WINAPI AllocConsole(VOID);
  229. WINBASEAPI WINBOOL WINAPI FreeConsole(VOID);
  230. WINBASEAPI WINBOOL WINAPI AttachConsole(DWORD dwProcessId);
  231. #define ATTACH_PARENT_PROCESS ((DWORD)-1)
  232. WINBASEAPI DWORD WINAPI GetConsoleTitleA(LPSTR lpConsoleTitle,DWORD nSize);
  233. WINBASEAPI DWORD WINAPI GetConsoleTitleW(LPWSTR lpConsoleTitle,DWORD nSize);
  234. WINBASEAPI WINBOOL WINAPI SetConsoleTitleA(LPCSTR lpConsoleTitle);
  235. WINBASEAPI WINBOOL WINAPI SetConsoleTitleW(LPCWSTR lpConsoleTitle);
  236. WINBASEAPI WINBOOL WINAPI ReadConsoleA(HANDLE hConsoleInput,LPVOID lpBuffer,DWORD nNumberOfCharsToRead,LPDWORD lpNumberOfCharsRead,LPVOID lpReserved);
  237. WINBASEAPI WINBOOL WINAPI ReadConsoleW(HANDLE hConsoleInput,LPVOID lpBuffer,DWORD nNumberOfCharsToRead,LPDWORD lpNumberOfCharsRead,LPVOID lpReserved);
  238. WINBASEAPI WINBOOL WINAPI WriteConsoleA(HANDLE hConsoleOutput,CONST VOID *lpBuffer,DWORD nNumberOfCharsToWrite,LPDWORD lpNumberOfCharsWritten,LPVOID lpReserved);
  239. WINBASEAPI WINBOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput,CONST VOID *lpBuffer,DWORD nNumberOfCharsToWrite,LPDWORD lpNumberOfCharsWritten,LPVOID lpReserved);
  240. #define CONSOLE_TEXTMODE_BUFFER 1
  241. WINBASEAPI HANDLE WINAPI CreateConsoleScreenBuffer(DWORD dwDesiredAccess,DWORD dwShareMode,CONST SECURITY_ATTRIBUTES *lpSecurityAttributes,DWORD dwFlags,LPVOID lpScreenBufferData);
  242. WINBASEAPI UINT WINAPI GetConsoleCP(VOID);
  243. WINBASEAPI WINBOOL WINAPI SetConsoleCP(UINT wCodePageID);
  244. WINBASEAPI UINT WINAPI GetConsoleOutputCP(VOID);
  245. WINBASEAPI WINBOOL WINAPI SetConsoleOutputCP(UINT wCodePageID);
  246. #define CONSOLE_FULLSCREEN 1
  247. #define CONSOLE_FULLSCREEN_HARDWARE 2
  248. WINBASEAPI WINBOOL WINAPI GetConsoleDisplayMode(LPDWORD lpModeFlags);
  249. WINBASEAPI HWND WINAPI GetConsoleWindow(VOID);
  250. WINBASEAPI DWORD WINAPI GetConsoleProcessList(LPDWORD lpdwProcessList,DWORD dwProcessCount);
  251. WINBASEAPI WINBOOL WINAPI AddConsoleAliasA(LPSTR Source,LPSTR Target,LPSTR ExeName);
  252. WINBASEAPI WINBOOL WINAPI AddConsoleAliasW(LPWSTR Source,LPWSTR Target,LPWSTR ExeName);
  253. WINBASEAPI DWORD WINAPI GetConsoleAliasA(LPSTR Source,LPSTR TargetBuffer,DWORD TargetBufferLength,LPSTR ExeName);
  254. WINBASEAPI DWORD WINAPI GetConsoleAliasW(LPWSTR Source,LPWSTR TargetBuffer,DWORD TargetBufferLength,LPWSTR ExeName);
  255. WINBASEAPI DWORD WINAPI GetConsoleAliasesLengthA(LPSTR ExeName);
  256. WINBASEAPI DWORD WINAPI GetConsoleAliasesLengthW(LPWSTR ExeName);
  257. WINBASEAPI DWORD WINAPI GetConsoleAliasExesLengthA(VOID);
  258. WINBASEAPI DWORD WINAPI GetConsoleAliasExesLengthW(VOID);
  259. WINBASEAPI DWORD WINAPI GetConsoleAliasesA(LPSTR AliasBuffer,DWORD AliasBufferLength,LPSTR ExeName);
  260. WINBASEAPI DWORD WINAPI GetConsoleAliasesW(LPWSTR AliasBuffer,DWORD AliasBufferLength,LPWSTR ExeName);
  261. WINBASEAPI DWORD WINAPI GetConsoleAliasExesA(LPSTR ExeNameBuffer,DWORD ExeNameBufferLength);
  262. WINBASEAPI DWORD WINAPI GetConsoleAliasExesW(LPWSTR ExeNameBuffer,DWORD ExeNameBufferLength);
  263. #ifdef __cplusplus
  264. }
  265. #endif
  266. #endif