1 | 'api_console.sbp
|
---|
2 |
|
---|
3 | #ifndef _INC_CONSOLE
|
---|
4 | #define _INC_CONSOLE
|
---|
5 |
|
---|
6 | #ifdef UNICODE
|
---|
7 | Const _FuncName_PeekConsoleInput = "PeekConsoleInputW"
|
---|
8 | Const _FuncName_ReadConsoleInput = "ReadConsoleInputW"
|
---|
9 | Const _FuncName_WriteConsoleInput = "WriteConsoleInputW"
|
---|
10 | Const _FuncName_ReadConsoleOutput = "ReadConsoleOutputW"
|
---|
11 | Const _FuncName_WriteConsoleOutput = "WriteConsoleOutputW"
|
---|
12 | Const _FuncName_ReadConsoleOutputCharacter = "ReadConsoleOutputCharacterW"
|
---|
13 | Const _FuncName_WriteConsoleOutputCharacter = "WriteConsoleOutputCharacterW"
|
---|
14 | Const _FuncName_FillConsoleOutputCharacter = "FillConsoleOutputCharacterW"
|
---|
15 | Const _FuncName_ScrollConsoleScreenBuffer = "ScrollConsoleScreenBufferW"
|
---|
16 | Const _FuncName_GetConsoleTitle = "GetConsoleTitleW"
|
---|
17 | Const _FuncName_SetConsoleTitle = "SetConsoleTitleW"
|
---|
18 | Const _FuncName_ReadConsole = "ReadConsoleW"
|
---|
19 | Const _FuncName_WriteConsole = "WriteConsoleW"
|
---|
20 | #else
|
---|
21 | Const _FuncName_PeekConsoleInput = "PeekConsoleInputA"
|
---|
22 | Const _FuncName_ReadConsoleInput = "ReadConsoleInputA"
|
---|
23 | Const _FuncName_WriteConsoleInput = "WriteConsoleInputA"
|
---|
24 | Const _FuncName_ReadConsoleOutput = "ReadConsoleOutputA"
|
---|
25 | Const _FuncName_WriteConsoleOutput = "WriteConsoleOutputA"
|
---|
26 | Const _FuncName_ReadConsoleOutputCharacter = "ReadConsoleOutputCharacterA"
|
---|
27 | Const _FuncName_WriteConsoleOutputCharacter = "WriteConsoleOutputCharacterA"
|
---|
28 | Const _FuncName_FillConsoleOutputCharacter = "FillConsoleOutputCharacterA"
|
---|
29 | Const _FuncName_ScrollConsoleScreenBuffer = "ScrollConsoleScreenBufferA"
|
---|
30 | Const _FuncName_GetConsoleTitle = "GetConsoleTitleA"
|
---|
31 | Const _FuncName_SetConsoleTitle = "SetConsoleTitleA"
|
---|
32 | Const _FuncName_ReadConsole = "ReadConsoleA"
|
---|
33 | Const _FuncName_WriteConsole = "WriteConsoleA"
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | Type COORD
|
---|
37 | X As Integer
|
---|
38 | Y As Integer
|
---|
39 | End Type
|
---|
40 | TypeDef PCOORD = *COORD
|
---|
41 |
|
---|
42 | Type SMALL_RECT
|
---|
43 | Left As Integer
|
---|
44 | Top As Integer
|
---|
45 | Right As Integer
|
---|
46 | Bottom As Integer
|
---|
47 | End Type
|
---|
48 | TypeDef PSMALL_RECT = *SMALL_RECT
|
---|
49 |
|
---|
50 | Type KEY_EVENT_RECORD
|
---|
51 | bKeyDown As BOOL
|
---|
52 | wRepeatCount As Word
|
---|
53 | wVirtualKeyCode As Word
|
---|
54 | wVirtualScanCode As Word
|
---|
55 | uChar As WCHAR
|
---|
56 | dwControlKeyState As DWord
|
---|
57 | End Type
|
---|
58 | TypeDef PKEY_EVENT_RECORD = *KEY_EVENT_RECORD
|
---|
59 |
|
---|
60 | Const RIGHT_ALT_PRESSED = &H0001
|
---|
61 | Const LEFT_ALT_PRESSED = &H0002
|
---|
62 | Const RIGHT_CTRL_PRESSED = &H0004
|
---|
63 | Const LEFT_CTRL_PRESSED = &H0008
|
---|
64 | Const SHIFT_PRESSED = &H0010
|
---|
65 | Const NUMLOCK_ON = &H0020
|
---|
66 | Const SCROLLLOCK_ON = &H0040
|
---|
67 | Const CAPSLOCK_ON = &H0080
|
---|
68 | Const ENHANCED_KEY = &H0100
|
---|
69 | Const NLS_DBCSCHAR = &H00010000
|
---|
70 | Const NLS_ALPHANUMERIC = &H00000000
|
---|
71 | Const NLS_KATAKANA = &H00020000
|
---|
72 | Const NLS_HIRAGANA = &H00040000
|
---|
73 | Const NLS_ROMAN = &H00400000
|
---|
74 | Const NLS_IME_CONVERSION = &H00800000
|
---|
75 | Const NLS_IME_DISABLE = &H20000000
|
---|
76 |
|
---|
77 | Type MOUSE_EVENT_RECORD
|
---|
78 | dwMousePosition As COORD
|
---|
79 | dwButtonState As DWord
|
---|
80 | dwControlKeyState As DWord
|
---|
81 | dwEventFlags As DWord
|
---|
82 | End Type
|
---|
83 | TypeDef PMOUSE_EVENT_RECORD = *MOUSE_EVENT_RECORD
|
---|
84 |
|
---|
85 | Const FROM_LEFT_1ST_BUTTON_PRESSED = &H0001
|
---|
86 | Const RIGHTMOST_BUTTON_PRESSED = &H0002
|
---|
87 | Const FROM_LEFT_2ND_BUTTON_PRESSED = &H0004
|
---|
88 | Const FROM_LEFT_3RD_BUTTON_PRESSED = &H0008
|
---|
89 | Const FROM_LEFT_4TH_BUTTON_PRESSED = &H0010
|
---|
90 |
|
---|
91 | Const MOUSE_MOVED = &H0001
|
---|
92 | Const DOUBLE_CLICK = &H0002
|
---|
93 | Const MOUSE_WHEELED = &H0004
|
---|
94 |
|
---|
95 | Type WINDOW_BUFFER_SIZE_RECORD
|
---|
96 | dwSize As COORD
|
---|
97 | End Type
|
---|
98 | TypeDef PWINDOW_BUFFER_SIZE_RECORD = *WINDOW_BUFFER_SIZE_RECORD
|
---|
99 |
|
---|
100 | Type MENU_EVENT_RECORD
|
---|
101 | dwCommandId As DWord
|
---|
102 | End Type
|
---|
103 | TypeDef PMENU_EVENT_RECORD = *MENU_EVENT_RECORD
|
---|
104 |
|
---|
105 | Type FOCUS_EVENT_RECORD
|
---|
106 | bSetFocus As BOOL
|
---|
107 | End Type
|
---|
108 | TypeDef PFOCUS_EVENT_RECORD = *FOCUS_EVENT_RECORD
|
---|
109 |
|
---|
110 | Type INPUT_RECORD
|
---|
111 | EventType As Word
|
---|
112 | ' Union Event
|
---|
113 | KeyEvent As KEY_EVENT_RECORD
|
---|
114 | ' MouseEvent As MOUSE_EVENT_RECORD
|
---|
115 | ' WindowBufferSizeEvent As WINDOW_BUFFER_SIZE_RECORD
|
---|
116 | ' MenuEvent As MENU_EVENT_RECORD
|
---|
117 | ' FocusEvent As FOCUS_EVENT_RECORD
|
---|
118 | ' End Union
|
---|
119 | End Type
|
---|
120 | TypeDef PINPUT_RECORD = *INPUT_RECORD
|
---|
121 |
|
---|
122 | Const KEY_EVENT = &H0001
|
---|
123 | Const MOUSE_EVENT = &H0002
|
---|
124 | Const WINDOW_BUFFER_SIZE_EVENT = &H0004
|
---|
125 | Const MENU_EVENT = &H0008
|
---|
126 | Const FOCUS_EVENT = &H0010
|
---|
127 |
|
---|
128 | Type CHAR_INFO
|
---|
129 | ' Union Char
|
---|
130 | ' UnicodeChar As WCHAR
|
---|
131 | AsciiChar[1] As SByte
|
---|
132 | ' End Union
|
---|
133 | Attributes As Word
|
---|
134 | End Type
|
---|
135 | TypeDef PCHAR_INFO = *CHAR_INFO
|
---|
136 |
|
---|
137 | Const FOREGROUND_BLUE = &H0001
|
---|
138 | Const FOREGROUND_GREEN = &H0002
|
---|
139 | Const FOREGROUND_RED = &H0004
|
---|
140 | Const FOREGROUND_INTENSITY = &H0008
|
---|
141 | Const BACKGROUND_BLUE = &H0010
|
---|
142 | Const BACKGROUND_GREEN = &H0020
|
---|
143 | Const BACKGROUND_RED = &H0040
|
---|
144 | Const BACKGROUND_INTENSITY = &H0080
|
---|
145 | Const COMMON_LVB_LEADING_BYTE = &H0100
|
---|
146 | Const COMMON_LVB_TRAILING_BYTE = &H0200
|
---|
147 | Const COMMON_LVB_GRID_HORIZONTAL = &H0400
|
---|
148 | Const COMMON_LVB_GRID_LVERTICAL = &H0800
|
---|
149 | Const COMMON_LVB_GRID_RVERTICAL = &H1000
|
---|
150 | Const COMMON_LVB_REVERSE_VIDEO = &H4000
|
---|
151 | Const COMMON_LVB_UNDERSCORE = &H8000
|
---|
152 | Const COMMON_LVB_SBCSDBCS = &H0300
|
---|
153 |
|
---|
154 | Type CONSOLE_SCREEN_BUFFER_INFO
|
---|
155 | dwSize As COORD
|
---|
156 | dwCursorPosition As COORD
|
---|
157 | wAttributes As Word
|
---|
158 | srWindow As SMALL_RECT
|
---|
159 | dwMaximumWindowSize As COORD
|
---|
160 | End Type
|
---|
161 | TypeDef PCONSOLE_SCREEN_BUFFER_INFO = *CONSOLE_SCREEN_BUFFER_INFO
|
---|
162 |
|
---|
163 | Type CONSOLE_CURSOR_INFO
|
---|
164 | dwSize As DWord
|
---|
165 | bVisible As BOOL
|
---|
166 | End Type
|
---|
167 | TypeDef PCONSOLE_CURSOR_INFO = *CONSOLE_CURSOR_INFO
|
---|
168 |
|
---|
169 | TypeDef PHANDLER_ROUTINE = *Function(CtrlType As DWord) As BOOL
|
---|
170 |
|
---|
171 | Const CTRL_C_EVENT = 0
|
---|
172 | Const CTRL_BREAK_EVENT = 1
|
---|
173 | Const CTRL_CLOSE_EVENT = 2
|
---|
174 | Const CTRL_LOGOFF_EVENT = 5
|
---|
175 | Const CTRL_SHUTDOWN_EVENT = 6
|
---|
176 |
|
---|
177 | Const ENABLE_PROCESSED_INPUT = &H0001
|
---|
178 | Const ENABLE_LINE_INPUT = &H0002
|
---|
179 | Const ENABLE_ECHO_INPUT = &H0004
|
---|
180 | Const ENABLE_WINDOW_INPUT = &H0008
|
---|
181 | Const ENABLE_MOUSE_INPUT = &H0010
|
---|
182 | Const ENABLE_PROCESSED_OUTPUT = &H0001
|
---|
183 | Const ENABLE_WRAP_AT_EOL_OUTPUT = &H0002
|
---|
184 |
|
---|
185 | Declare Function PeekConsoleInput Lib "kernel32" Alias _FuncName_PeekConsoleInput (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
|
---|
186 | Declare Function ReadConsoleInput Lib "kernel32" Alias _FuncName_ReadConsoleInput (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
|
---|
187 | Declare Function WriteConsoleInput Lib "kernel32" Alias _FuncName_WriteConsoleInput (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsWritten As DWord) As BOOL
|
---|
188 | Declare Function ReadConsoleOutput Lib "kernel32" Alias _FuncName_ReadConsoleOutput (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpReadRegion As SMALL_RECT) As BOOL
|
---|
189 | Declare Function WriteConsoleOutput Lib "kernel32" Alias _FuncName_WriteConsoleOutput (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpWriteRegion As SMALL_RECT) As BOOL
|
---|
190 | Declare Function ReadConsoleOutputCharacter Lib "kernel32" Alias _FuncName_ReadConsoleOutputCharacter (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfCharsRead As DWord) As BOOL
|
---|
191 | Declare Function ReadConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfAttrsRead As DWord) As BOOL
|
---|
192 | Declare Function WriteConsoleOutputCharacter Lib "kernel32" Alias _FuncName_WriteConsoleOutputCharacter (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
|
---|
193 | Declare Function WriteConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
|
---|
194 | Declare Function FillConsoleOutputCharacter Lib "kernel32" Alias _FuncName_FillConsoleOutputCharacter (hConsoleOutput As HANDLE, cCharacter As Char, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
|
---|
195 | Declare Function FillConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttribute As Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
|
---|
196 | Declare Function GetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, ByRef lpMode As DWord) As BOOL
|
---|
197 | Declare Function GetNumberOfConsoleInputEvents Lib "kernel32" (hConsoleInput As HANDLE, ByRef lpNumberOfEvents As DWord) As BOOL
|
---|
198 | Declare Function GetConsoleScreenBufferInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleScreenBufferInfo As CONSOLE_SCREEN_BUFFER_INFO) As BOOL
|
---|
199 | Declare Function GetLargestConsoleWindowSize Lib "kernel32" (hConsoleOutput As HANDLE) As DWord
|
---|
200 | Declare Function GetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
|
---|
201 | Declare Function GetNumberOfConsoleMouseButtons Lib "kernel32" (ByRef lpNumberOfMouseButtons As DWord) As BOOL
|
---|
202 | Declare Function SetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, dwMode As DWord) As BOOL
|
---|
203 | Declare Function SetConsoleActiveScreenBuffer Lib "kernel32" (hConsoleOutput As HANDLE) As BOOL
|
---|
204 | Declare Function FlushConsoleInputBuffer Lib "kernel32" (hConsoleInput As HANDLE) As BOOL
|
---|
205 | Declare Function SetConsoleScreenBufferSize Lib "kernel32" (hConsoleOutput As HANDLE, dwSize As DWord) As BOOL
|
---|
206 | Declare Function SetConsoleCursorPosition Lib "kernel32" (hConsoleOutput As HANDLE, dwCursorPosition As DWord) As BOOL
|
---|
207 | Declare Function SetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
|
---|
208 | Declare Function ScrollConsoleScreenBuffer Lib "kernel32" Alias _FuncName_ScrollConsoleScreenBuffer (hConsoleOutput As HANDLE, ByRef lpScrollRectangle As SMALL_RECT, lpClipRectangle As *SMALL_RECT, ByRef dwDestinationOrigin As COORD, lpFill As *CHAR_INFO) As BOOL
|
---|
209 | Declare Function SetConsoleWindowInfo Lib "kernel32" (hConsoleOutput As HANDLE, bAbsolute As BOOL, ByRef lpConsoleWindow As SMALL_RECT) As BOOL
|
---|
210 | Declare Function SetConsoleTextAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttributes As Word) As BOOL
|
---|
211 | Declare Function SetConsoleCtrlHandler Lib "kernel32" (HandlerRoutine As PHANDLER_ROUTINE, Add As BOOL) As BOOL
|
---|
212 | Declare Function GenerateConsoleCtrlEvent Lib "kernel32" (dwCtrlEvent As DWord, dwProcessGroupId As DWord) As BOOL
|
---|
213 | Declare Function AllocConsole Lib "kernel32" () As BOOL
|
---|
214 | Declare Function FreeConsole Lib "kernel32" () As BOOL
|
---|
215 | Declare Function GetConsoleTitle Lib "kernel32" Alias _FuncName_GetConsoleTitle (lpConsoleTitle As LPSTR, nSize As DWord) As DWord
|
---|
216 | Declare Function SetConsoleTitle Lib "kernel32" Alias _FuncName_SetConsoleTitle (lpConsoleTitle As LPSTR) As BOOL
|
---|
217 | Declare Function ReadConsole Lib "kernel32" Alias _FuncName_ReadConsole (hConsoleInput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToRead As DWord, ByRef lpNumberOfCharsRead As DWord, lpReserved As VoidPtr) As BOOL
|
---|
218 | Declare Function WriteConsole Lib "kernel32" Alias _FuncName_WriteConsole (hConsoleOutput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToWrite As DWord, ByRef lpNumberOfCharsWritten As DWord, lpReserved As VoidPtr) As BOOL
|
---|
219 |
|
---|
220 | Const CONSOLE_TEXTMODE_BUFFER = 1
|
---|
221 |
|
---|
222 | Declare Function CreateConsoleScreenBuffer Lib "kernel32" (dwDesiredAccess As DWord, dwShareMode As DWord, lpSecurityAttributes As *SECURITY_ATTRIBUTES, dwFlags As DWord, lpScreenBufferData As VoidPtr) As HANDLE
|
---|
223 | Declare Function GetConsoleCP Lib "kernel32" () As DWord
|
---|
224 | Declare Function SetConsoleCP Lib "kernel32" (wCodePageID As DWord) As BOOL
|
---|
225 | Declare Function GetConsoleOutputCP Lib "kernel32" () As DWord
|
---|
226 | Declare Function SetConsoleOutputCP Lib "kernel32" (wCodePageID As DWord) As BOOL
|
---|
227 |
|
---|
228 |
|
---|
229 |
|
---|
230 | #endif '_INC_CONSOLE
|
---|