source: Include/api_console.sbp@ 242

Last change on this file since 242 was 142, checked in by イグトランス (egtra), 18 years ago

Environment, OperatingSystem, Versionの追加、Unicode対応修正ほか

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