' ########################################################################################
' Microsoft Windows
' File: WinCon.inc
' Contents: Public data structures, data types, and procedures exported by the NT
' console subsystem.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
' Note: windows.inc must be included before this file, but can't be done here.
' You must do it in your application.
#IF NOT %DEF(PBX_WinCon_PBI)
#DEFINE PBX_WinCon_PBI
%EQUATE `WINCON_INC = 1
#IF NOT %DEF(%NOGDI)
#INCLUDE ONCE "Legacy/Platform/WinGDI.inc"
#ENDIF
' // Size = 4 bytes
TYPE COORD WORD
 x AS INTEGER ' SHORT X
 y AS INTEGER ' SHORT Y
END TYPE
TYPE SMALL_RECT1 WORD
 xLeft AS INTEGER
 xTop AS INTEGER
 xRight AS INTEGER
 xBottom AS INTEGER
END TYPE
TYPE SMALL_RECT2 WORD
 nLeft AS INTEGER
 nTop AS INTEGER
 nRight AS INTEGER
 nBottom AS INTEGER
END TYPE
TYPE SMALL_RECT3 WORD
 Left AS INTEGER
 Top AS INTEGER
 Right AS INTEGER
 Bottom AS INTEGER
END TYPE
' // Size = 8 bytes
UNION SMALL_RECT WORD
 SMALL_RECT1
 SMALL_RECT2
 SMALL_RECT3
END UNION
'typedef struct _KEY_EVENT_RECORD {
' BOOL bKeyDown;
' WORD wRepeatCount;
' WORD wVirtualKeyCode;
' WORD wVirtualScanCode;
' union {
' WCHAR UnicodeChar;
' CHAR AsciiChar;
' } uChar;
' DWORD dwControlKeyState;
'} KEY_EVENT_RECORD, *PKEY_EVENT_RECORD;
' // Size = 2 bytes
UNION KEY_EVENT_RECORD_UNION_uChar WORD
 UnicodeChar AS WORD ' WCHAR UnicodeChar
 AsciiChar AS BYTE ' CHAR AsciiChar
END UNION
' // Size = 16 bytes
TYPE KEY_EVENT_RECORD DWORD FILL
 bKeyDown AS LONG ' BOOL bKeyDown
 wRepeatCount AS WORD ' WORD wRepeatCount
 wVirtualKeyCode AS WORD ' WORD wVirtualKeyCode
 wVirtualScanCode AS WORD ' WORD wVirtualScanCode
 KEY_EVENT_RECORD_UNION_uChar
 dwControlKeyState AS DWORD ' DWORD dwControlKeyState
END TYPE
'//
'// ControlKeyState flags
'//
%EQUATE `RIGHT_ALT_PRESSED = &H0001 ' the right alt key is pressed.
%EQUATE `LEFT_ALT_PRESSED = &H0002 ' the left alt key is pressed.
%EQUATE `RIGHT_CTRL_PRESSED = &H0004 ' the right ctrl key is pressed.
%EQUATE `LEFT_CTRL_PRESSED = &H0008 ' the left ctrl key is pressed.
%EQUATE `SHIFT_PRESSED = &H0010 ' the shift key is pressed.
%EQUATE `NUMLOCK_ON = &H0020 ' the numlock light is on.
%EQUATE `SCROLLLOCK_ON = &H0040 ' the scrolllock light is on.
%EQUATE `CAPSLOCK_ON = &H0080 ' the capslock light is on.
%EQUATE `ENHANCED_KEY = &H0100 ' the key is enhanced.
%EQUATE `NLS_DBCSCHAR = &H00010000 ' // DBCS for JPN: SBCS/DBCS mode.
%EQUATE `NLS_ALPHANUMERIC = &H00000000 ' // DBCS for JPN: Alphanumeric mode.
%EQUATE `NLS_KATAKANA = &H00020000 ' // DBCS for JPN: Katakana mode.
%EQUATE `NLS_HIRAGANA = &H00040000 ' // DBCS for JPN: Hiragana mode.
%EQUATE `NLS_ROMAN = &H00400000 ' // DBCS for JPN: Roman/Noroman mode.
%EQUATE `NLS_IME_CONVERSION = &H00800000 ' // DBCS for JPN: IME conversion.
%EQUATE `NLS_IME_DISABLE = &H20000000 ' // DBCS for JPN: IME enable/disable.
' // Size = 16 bytes
TYPE MOUSE_EVENT_RECORD DWORD FILL
 dwMousePosition AS COORD ' COORD dwMousePosition
 dwButtonState AS DWORD ' DWORD dwButtonState
 dwControlKeyState AS DWORD ' DWORD dwControlKeyState
 dwEventFlags AS DWORD ' DWORD dwEventFlags
END TYPE
'//
'// ButtonState flags
'//
%EQUATE `FROM_LEFT_1ST_BUTTON_PRESSED = &H0001
%EQUATE `RIGHTMOST_BUTTON_PRESSED = &H0002
%EQUATE `FROM_LEFT_2ND_BUTTON_PRESSED = &H0004
%EQUATE `FROM_LEFT_3RD_BUTTON_PRESSED = &H0008
%EQUATE `FROM_LEFT_4TH_BUTTON_PRESSED = &H0010
'//
'// EventFlags
'//
%EQUATE `MOUSE_MOVED = &H0001
%EQUATE `DOUBLE_CLICK = &H0002
%EQUATE `MOUSE_WHEELED = &H0004
'#if(_WIN32_WINNT >= 0x0600)
%EQUATE `MOUSE_HWHEELED = &H0008
'#endif /* _WIN32_WINNT >= 0x0600 */
' // Size = 4 bytes
TYPE WINDOW_BUFFER_SIZE_RECORD WORD
 dwSize AS COORD ' COORD dwSize
END TYPE
' // Size = 4 bytes
TYPE MENU_EVENT_RECORD DWORD
 dwCommandId AS DWORD ' UINT dwCommandId
END TYPE
' // Size = 4 bytes
TYPE FOCUS_EVENT_RECORD DWORD
 bSetFocus AS LONG ' BOOL bSetFocus
END TYPE
'typedef struct _INPUT_RECORD {
' WORD EventType;
' union {
' KEY_EVENT_RECORD KeyEvent;
' MOUSE_EVENT_RECORD MouseEvent;
' WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
' MENU_EVENT_RECORD MenuEvent;
' FOCUS_EVENT_RECORD FocusEvent;
' } Event;
'} INPUT_RECORD, *PINPUT_RECORD;
' // Size = 16 bytes
UNION INPUT_RECORD_UNION_Event DWORD
 KeyEvent AS KEY_EVENT_RECORD
 MouseEvent AS MOUSE_EVENT_RECORD
 WindowBufferSizeEvent AS WINDOW_BUFFER_SIZE_RECORD
 MenuEvent AS MENU_EVENT_RECORD
 FocusEvent AS FOCUS_EVENT_RECORD
END UNION
' // Size = 20 bytes
TYPE INPUT_RECORD_UNION DWORD
 Event AS INPUT_RECORD_UNION_Event
 INPUT_RECORD_UNION_Event
END TYPE
TYPE INPUT_RECORD DWORD
 EventType AS WORD
 INPUT_RECORD_UNION
END TYPE
'//
'// EventType flags:
'//
%EQUATE `KEY_EVENT = &H0001 ' Event contains key event record
%EQUATE `MOUSE_EVENT = &H0002 ' Event contains mouse event record
%EQUATE `WINDOW_BUFFER_SIZE_EVENT = &H0004 ' Event contains window change event record
%EQUATE `MENU_EVENT = &H0008 ' Event contains menu event record
%EQUATE `FOCUS_EVENT = &H0010 ' event contains focus change
'typedef struct _CHAR_INFO {
' union {
' WCHAR UnicodeChar;
' CHAR AsciiChar;
' } Char;
' WORD Attributes;
'} CHAR_INFO, *PCHAR_INFO;
' // Size = 2 bytes
UNION CHAR_INFO_UNION_Char WORD
 UnicodeChar AS WORD
 AsciiChar AS BYTE
END UNION
' // Size = 4 bytes
TYPE CHAR_INFO WORD
 Char AS CHAR_INFO_UNION_Char
 Attributes AS WORD
END TYPE
'//
'// Attributes flags:
'//
%EQUATE `FOREGROUND_BLUE = &H0001 ' text color contains blue.
%EQUATE `FOREGROUND_GREEN = &H0002 ' text color contains green.
%EQUATE `FOREGROUND_RED = &H0004 ' text color contains red.
%EQUATE `FOREGROUND_INTENSITY = &H0008 ' text color is intensified.
%EQUATE `BACKGROUND_BLUE = &H0010 ' background color contains blue.
%EQUATE `BACKGROUND_GREEN = &H0020 ' background color contains green.
%EQUATE `BACKGROUND_RED = &H0040 ' background color contains red.
%EQUATE `BACKGROUND_INTENSITY = &H0080 ' background color is intensified.
%EQUATE `COMMON_LVB_LEADING_BYTE = &H0100 ' // Leading Byte of DBCS
%EQUATE `COMMON_LVB_TRAILING_BYTE = &H0200 ' // Trailing Byte of DBCS
%EQUATE `COMMON_LVB_GRID_HORIZONTAL = &H0400 ' // DBCS: Grid attribute: top horizontal.
%EQUATE `COMMON_LVB_GRID_LVERTICAL = &H0800 ' // DBCS: Grid attribute: left vertical.
%EQUATE `COMMON_LVB_GRID_RVERTICAL = &H1000 ' // DBCS: Grid attribute: right vertical.
%EQUATE `COMMON_LVB_REVERSE_VIDEO = &H4000 ' // DBCS: Reverse fore/back ground attribute.
%EQUATE `COMMON_LVB_UNDERSCORE = &H8000 ' // DBCS: Underscore.
%EQUATE `COMMON_LVB_SBCSDBCS = &H0300 ' // SBCS or DBCS flag.
' // Size = 22 bytes
TYPE CONSOLE_SCREEN_BUFFER_INFO WORD
 dwSize AS COORD ' COORD dwSize
 dwCursorPosition AS COORD ' COORD dwCursorPosition
 wAttributes AS WORD ' WORD wAttributes
 srWindow AS SMALL_RECT ' SMALL_RECT srWindow
 dwMaximumWindowSize AS COORD ' COORD dwMaximumWindowSize
END TYPE
' // Size = 96 bytes
TYPE CONSOLE_SCREEN_BUFFER_INFOEX WORD
 cbSize AS DWORD ' ULONG
 dwSize AS COORD ' COORD
 dwCursorPosition AS COORD ' COORD
 wAttributes AS WORD ' WORD
 srWindow AS SMALL_RECT ' SMALL_RECT
 dwMaximumWindowSize AS COORD ' COORD
 wPopupAttributes AS WORD ' WORD
 bFullscreenSupported AS LONG
 ColorTable(15) AS DWORD ' COLORREF
END TYPE
' // Size = 8 bytes
TYPE CONSOLE_CURSOR_INFO DWORD
 dwSize AS DWORD ' DWORD dwSize
 bVisible AS LONG ' BOOL bVisible
END TYPE
' // Size = 8 bytes
TYPE CONSOLE_FONT_INFO DWORD
 nFont AS DWORD ' DWORD nFont
 dwFontSize AS COORD ' COORD dwFontSize
END TYPE
'#if(_WIN32_WINNT >= 0x0500)
' // Size = 16 bytes
TYPE CONSOLE_SELECTION_INFO DWORD
 dwFlags AS DWORD ' DWORD dwFlags
 dwSelectionAnchor AS COORD ' COORD dwSelectionAnchor
 srSelection AS SMALL_RECT ' SMALL_RECT srSelection
END TYPE
#IF NOT %DEF(%NOGDI)
' // Size = 84 bytes
TYPE CONSOLE_FONT_INFOEX DWORD
 cbSize AS DWORD ' ULONG
 nFont AS DWORD
 dwFontSize AS COORD ' COORD
 FontFamily AS DWORD ' UINT
 FontWeight AS DWORD ' UINT
 FaceName AS WSTRINGZ * %LF_FACESIZE ' WCHAR
END TYPE
#ENDIF
%EQUATE `HISTORY_NO_DUP_FLAG = &H1
' // Size = 16 bytes
TYPE CONSOLE_HISTORY_INFO DWORD
 cbSize AS DWORD ' UINT
 HistoryBufferSize AS DWORD ' UINT
 NumberOfHistoryBuffers AS DWORD ' UINT
 dwFlags AS DWORD
END TYPE
'//
'// Selection flags
'//
%EQUATE `CONSOLE_NO_SELECTION = &H0000
%EQUATE `CONSOLE_SELECTION_IN_PROGRESS = &H0001 ' // selection has begun
%EQUATE `CONSOLE_SELECTION_NOT_EMPTY = &H0002 ' // non-null select rectangle
%EQUATE `CONSOLE_MOUSE_SELECTION = &H0004 ' // selecting with mouse
%EQUATE `CONSOLE_MOUSE_DOWN = &H0008 ' // mouse is down
'#endif /* _WIN32_WINNT >= 0x0500 */
'//
'// typedef for ctrl-c handler routines
'//
'typedef
'(WINAPI *PHANDLER_ROUTINE)(
' DWORD CtrlType
' );
%EQUATE `CTRL_C_EVENT = 0
%EQUATE `CTRL_BREAK_EVENT = 1
%EQUATE `CTRL_CLOSE_EVENT = 2
'// 3 is reserved!
'// 4 is reserved!
%EQUATE `CTRL_LOGOFF_EVENT = 5
%EQUATE `CTRL_SHUTDOWN_EVENT = 6
'//
'// Input Mode flags:
'//
%EQUATE `ENABLE_PROCESSED_INPUT = &H0001
%EQUATE `ENABLE_LINE_INPUT = &H0002
%EQUATE `ENABLE_ECHO_INPUT = &H0004
%EQUATE `ENABLE_WINDOW_INPUT = &H0008
%EQUATE `ENABLE_MOUSE_INPUT = &H0010
%EQUATE `ENABLE_INSERT_MODE = &H0020
%EQUATE `ENABLE_QUICK_EDIT_MODE = &H0040
%EQUATE `ENABLE_EXTENDED_FLAGS = &H0080
%EQUATE `ENABLE_AUTO_POSITION = &H0100
'//
'// Output Mode flags:
'//
%EQUATE `ENABLE_PROCESSED_OUTPUT = &H0001
%EQUATE `ENABLE_WRAP_AT_EOL_OUTPUT = &H0002
'//
'// direct API definitions.
'//
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION PeekConsoleInputA LIB "KERNEL32.dll" ALIAS "PeekConsoleInputA" (BYVAL hConsoleInput AS QUAD, BYVAL lpBuffer AS INPUT_RECORD PTR, BYVAL nLength AS QUAD, lpNumberOfEventsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION PeekConsoleInputA LIB "kernel32.dll" ALIAS "PeekConsoleInputA" ( BYVAL hConsoleInput AS QUAD , BYREF lpBuffer AS INPUT_RECORD , BYVAL nLength AS QUAD , BYREF lpNumberOfEventsRead AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION PeekConsoleInputW LIB "KERNEL32.dll" ALIAS "PeekConsoleInputW" (BYVAL hConsoleInput AS QUAD, BYVAL lpBuffer AS INPUT_RECORD PTR, BYVAL nLength AS QUAD, lpNumberOfEventsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION PeekConsoleInputW LIB "kernel32.dll" ALIAS "PeekConsoleInputW" ( BYVAL hConsoleInput AS QUAD , BYREF INPUT_RECORD , BYVAL nLength AS QUAD , BYREF lpNumberOfEventsRead AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO PeekConsoleInput = PeekConsoleInputW
#ELSE
 MACRO PeekConsoleInput = PeekConsoleInputA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadConsoleInputA LIB "KERNEL32.dll" ALIAS "ReadConsoleInputA" (BYVAL hConsoleInput AS QUAD, BYVAL lpBuffer AS INPUT_RECORD PTR, BYVAL nNumberOfCharsToRead AS LONG, lpNumberOfCharsRead AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ReadConsoleInputA LIB "kernel32.dll" ALIAS "ReadConsoleInputA" ( BYVAL hConsoleInput AS QUAD , BYREF lpBuffer AS INPUT_RECORD , BYVAL nLength AS QUAD , BYREF lpNumberOfEventsRead AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadConsoleInputW LIB "KERNEL32.dll" ALIAS "ReadConsoleInputW" (BYVAL hConsoleInput AS QUAD, BYVAL lpBuffer AS INPUT_RECORD PTR, BYVAL nNumberOfCharsToRead AS LONG, lpNumberOfCharsRead AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ReadConsoleInputW LIB "kernel32.dll" ALIAS "ReadConsoleInputW" ( BYVAL hConsoleInput AS QUAD , BYREF lpBuffer AS INPUT_RECORD , BYVAL nLength AS QUAD , BYREF lpNumberOfEventsRead AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ReadConsoleInput = ReadConsoleInputW
#ELSE
 MACRO ReadConsoleInput = ReadConsoleInputA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteConsoleInputA LIB "KERNEL32.dll" ALIAS "WriteConsoleInputA" (BYVAL hConsoleInput AS QUAD, BYVAL lpBuffer AS INPUT_RECORD PTR, BYVAL nLength AS QUAD, lpNumberOfEventsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION WriteConsoleInputA LIB "kernel32.dll" ALIAS "WriteConsoleInputA" ( BYVAL hConsoleInput AS QUAD , BYREF lpBuffer AS INPUT_RECORD , BYVAL nLength AS QUAD , BYREF lpNumberOfEventsWritten AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteConsoleInputW LIB "KERNEL32.dll" ALIAS "WriteConsoleInputW" (BYVAL hConsoleInput AS QUAD, BYVAL lpBuffer AS INPUT_RECORD PTR, BYVAL nLength AS QUAD, lpNumberOfEventsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION WriteConsoleInputW LIB "kernel32.dll" ALIAS "WriteConsoleInputW" ( BYVAL hConsoleInput AS QUAD , BYREF lpBuffer AS INPUT_RECORD , BYVAL nLength AS QUAD , BYREF lpNumberOfEventsWritten AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO WriteConsoleInput = WriteConsoleInputW
#ELSE
 MACRO WriteConsoleInput = WriteConsoleInputA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadConsoleOutputA LIB "KERNEL32.dll" ALIAS "ReadConsoleOutputA" (BYVAL hConsoleOutput AS QUAD, BYVAL lpBuffer AS CHAR_INFO PTR, BYVAL dwBufferSize AS QUAD, BYVAL dwBufferCoord AS QUAD, lpReadRegion AS SMALL_RECT) AS LONG
#ELSE
DECLARE FUNCTION ReadConsoleOutputA LIB "kernel32.dll" ALIAS "ReadConsoleOutputA" ( BYVAL hConsoleOutput AS QUAD , BYREF lpBuffer AS CHAR_INFO , BYVAL dwBufferSize AS COORD , BYVAL dwBufferCoord AS COORD , BYREF lpReadRegion AS SMALL_RECT ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadConsoleOutputW LIB "KERNEL32.dll" ALIAS "ReadConsoleOutputW" (BYVAL hConsoleOutput AS QUAD, BYVAL lpBuffer AS CHAR_INFO PTR, BYVAL dwBufferSize AS QUAD, BYVAL dwBufferCoord AS QUAD, lpReadRegion AS SMALL_RECT) AS LONG
#ELSE
DECLARE FUNCTION ReadConsoleOutputW LIB "kernel32.dll" ALIAS "ReadConsoleOutputW" ( BYVAL hConsoleOutput AS QUAD , BYREF lpBuffer AS CHAR_INFO , BYVAL dwBufferSize AS COORD , BYVAL dwBufferCoord AS COORD , BYREF lpReadRegion AS SMALL_RECT ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ReadConsoleOutput = ReadConsoleOutputW
#ELSE
 MACRO ReadConsoleOutput = ReadConsoleOutputA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteConsoleOutputA LIB "KERNEL32.dll" ALIAS "WriteConsoleOutputA" (BYVAL hConsoleOutput AS QUAD, BYVAL lpBuffer AS CHAR_INFO PTR, BYVAL dwBufferSize AS QUAD, BYVAL dwBufferCoord AS QUAD, lpWriteRegion AS SMALL_RECT) AS LONG
#ELSE
DECLARE FUNCTION WriteConsoleOutputA LIB "kernel32.dll" ALIAS "WriteConsoleOutputA" ( BYVAL hConsoleOutput AS QUAD , BYREF lpBuffer AS CHAR_INFO , BYVAL dwBufferSize AS COORD , BYVAL dwBufferCoord AS COORD , BYREF lpWriteRegion AS SMALL_RECT ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteConsoleOutputW LIB "KERNEL32.dll" ALIAS "WriteConsoleOutputW" (BYVAL hConsoleOutput AS QUAD, BYVAL lpBuffer AS CHAR_INFO PTR, BYVAL dwBufferSize AS QUAD, BYVAL dwBufferCoord AS QUAD, lpWriteRegion AS SMALL_RECT) AS LONG
#ELSE
DECLARE FUNCTION WriteConsoleOutputW LIB "kernel32.dll" ALIAS "WriteConsoleOutputW" ( BYVAL hConsoleOutput AS QUAD , BYREF lpBuffer AS CHAR_INFO , BYVAL dwBufferSize AS COORD , BYVAL dwBufferCoord AS COORD , BYREF lpWriteRegion AS SMALL_RECT ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO WriteConsoleOutput = WriteConsoleOutputW
#ELSE
 MACRO WriteConsoleOutput = WriteConsoleOutputA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadConsoleOutputCharacterA LIB "KERNEL32.dll" ALIAS "ReadConsoleOutputCharacterA" (BYVAL hConsoleOutput AS QUAD, szCharacter AS ASCIIZ, BYVAL nLength AS QUAD, BYVAL dwReadCoord AS QUAD, lpNumberOfCharsRead AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION ReadConsoleOutputCharacterA LIB "kernel32.dll" ALIAS "ReadConsoleOutputCharacterA" ( BYVAL hConsoleOutput AS QUAD , BYREF lpCharacter AS ASCIIZ , BYVAL nLength AS QUAD , BYVAL dwReadCoord AS COORD , BYREF lpNumberOfCharsRead AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadConsoleOutputCharacterW LIB "KERNEL32.dll" ALIAS "ReadConsoleOutputCharacterW" (BYVAL hConsoleOutput AS QUAD, szCharacter AS WSTRINGZ, BYVAL nLength AS QUAD, BYVAL dwReadCoord AS QUAD, lpNumberOfCharsRead AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION ReadConsoleOutputCharacterW LIB "kernel32.dll" ALIAS "ReadConsoleOutputCharacterW" ( BYVAL hConsoleOutput AS QUAD , BYREF lpCharacter AS WSTRINGZ , BYVAL nLength AS QUAD , BYVAL dwReadCoord AS COORD , BYREF lpNumberOfCharsRead AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ReadConsoleOutputCharacter = ReadConsoleOutputCharacterW
#ELSE
 MACRO ReadConsoleOutputCharacter = ReadConsoleOutputCharacterA
#ENDIF
' lpAttribute has been declared as BYREF ANY instead of DWORD because it can be a single WORD
' variable (one attribute) or a buffer of nLength * sizeof(WORD).
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadConsoleOutputAttribute LIB "KERNEL32.dll" ALIAS "ReadConsoleOutputAttribute" (BYVAL hConsoleOutput AS QUAD, BYVAL lpAttribute AS WORD PTR, BYVAL nLength AS QUAD, BYVAL dwReadCoord AS QUAD, lpNumberOfAttrsRead AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION ReadConsoleOutputAttribute LIB "kernel32.dll" ALIAS "ReadConsoleOutputAttribute" ( BYVAL hConsoleOutput AS QUAD , BYREF lpAttribute AS ANY , BYVAL nLength AS QUAD , BYVAL dwReadCoord AS COORD , BYREF lpNumberOfAttrsRead AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteConsoleOutputCharacterA LIB "KERNEL32.dll" ALIAS "WriteConsoleOutputCharacterA" (BYVAL hConsoleOutput AS QUAD, szCharacter AS ASCIIZ, BYVAL nLength AS QUAD, BYVAL dwWriteCoord AS QUAD, lpNumberOfCharsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION WriteConsoleOutputCharacterA LIB "kernel32.dll" ALIAS "WriteConsoleOutputCharacterA" ( BYVAL hConsoleOutput AS QUAD , BYREF lpCharacter AS ASCIIZ , BYVAL nLength AS QUAD , BYVAL dwWriteCoord AS COORD , BYREF lpNumberOfCharsWritten AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteConsoleOutputCharacterW LIB "KERNEL32.dll" ALIAS "WriteConsoleOutputCharacterW" (BYVAL hConsoleOutput AS QUAD, szCharacter AS WSTRINGZ, BYVAL nLength AS QUAD, BYVAL dwWriteCoord AS QUAD, lpNumberOfCharsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION WriteConsoleOutputCharacterW LIB "kernel32.dll" ALIAS "WriteConsoleOutputCharacterW" ( BYVAL hConsoleOutput AS QUAD , BYREF lpCharacter AS WSTRINGZ , BYVAL nLength AS QUAD , BYVAL dwWriteCoord AS COORD , BYREF lpNumberOfCharsWritten AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO WriteConsoleOutputCharacter = WriteConsoleOutputCharacterW
#ELSE
 MACRO WriteConsoleOutputCharacter = WriteConsoleOutputCharacterA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteConsoleOutputAttribute LIB "KERNEL32.dll" ALIAS "WriteConsoleOutputAttribute" (BYVAL hConsoleOutput AS QUAD, BYVAL lpAttribute AS WORD PTR, BYVAL nLength AS QUAD, BYVAL dwWriteCoord AS QUAD, lpNumberOfAttrsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION WriteConsoleOutputAttribute LIB "kernel32.dll" ALIAS "WriteConsoleOutputAttribute" ( BYVAL hConsoleOutput AS QUAD , BYREF lpAttribute AS WORD , BYVAL nLength AS QUAD , BYVAL dwWriteCoord AS COORD , BYREF lpNumberOfAttrsWritten AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION FillConsoleOutputCharacterA LIB "KERNEL32.dll" ALIAS "FillConsoleOutputCharacterA" (BYVAL hConsoleOutput AS QUAD, BYVAL bCharacter AS BYTE, BYVAL nLength AS QUAD, BYVAL dwWriteCoord AS QUAD, lpNumberOfCharsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION FillConsoleOutputCharacterA LIB "kernel32.dll" ALIAS "FillConsoleOutputCharacterA" ( BYVAL hConsoleOutput AS QUAD , BYVAL cCharacter AS BYTE , BYVAL nLength AS QUAD , BYVAL dwWriteCoord AS COORD , BYREF lpNumberOfCharsWritten AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION FillConsoleOutputCharacterW LIB "KERNEL32.dll" ALIAS "FillConsoleOutputCharacterW" (BYVAL hConsoleOutput AS QUAD, BYVAL bCharacter AS WORD, BYVAL nLength AS QUAD, BYVAL dwWriteCoord AS QUAD, lpNumberOfCharsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION FillConsoleOutputCharacterW LIB "kernel32.dll" ALIAS "FillConsoleOutputCharacterW" ( BYVAL hConsoleOutput AS QUAD , BYVAL cCharacter AS WORD , BYVAL nLength AS QUAD , BYVAL dwWriteCoord AS COORD , BYREF lpNumberOfCharsWritten AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO FillConsoleOutputCharacter = FillConsoleOutputCharacterW
#ELSE
 MACRO FillConsoleOutputCharacter = FillConsoleOutputCharacterA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION FillConsoleOutputAttribute LIB "KERNEL32.dll" ALIAS "FillConsoleOutputAttribute" (BYVAL hConsoleOutput AS QUAD, BYVAL wAttribute AS WORD, BYVAL nLength AS QUAD, BYVAL dwWriteCoord AS QUAD, lpNumberOfAttrsWritten AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION FillConsoleOutputAttribute LIB "kernel32.dll" ALIAS "FillConsoleOutputAttribute" ( BYVAL hConsoleOutput AS QUAD , BYVAL wAttribute AS WORD , BYVAL nLength AS QUAD , BYVAL dwWriteCoord AS COORD , BYREF lpNumberOfAttrsWritten AS QUAD ) AS LONG
#ENDIF
DECLARE FUNCTION GetConsoleMode LIB "kernel32.dll" ALIAS "GetConsoleMode" ( BYVAL hConsoleHandle AS QUAD , BYREF lpMode AS QUAD ) AS LONG
DECLARE FUNCTION GetNumberOfConsoleInputEvents LIB "kernel32.dll" ALIAS "GetNumberOfConsoleInputEvents" ( BYVAL hConsoleInput AS QUAD
 , BYREF lpNumberOfEvents AS DWORD
 ) AS LONG
'#define CONSOLE_REAL_OUTPUT_HANDLE (LongToHandle(-2))
'#define CONSOLE_REAL_INPUT_HANDLE (LongToHandle(-3))
#IF %DEF(%USEPNDECL)
%EQUATE `CONSOLE_REAL_OUTPUT_HANDLE = -2
%EQUATE `CONSOLE_REAL_INPUT_HANDLE = -3
#ELSE
%EQUATE `CONSOLE_REAL_OUTPUT_HANDLE = &HFFFFFFFE
%EQUATE `CONSOLE_REAL_INPUT_HANDLE = &HFFFFFFFD
#ENDIF
DECLARE FUNCTION GetConsoleScreenBufferInfo LIB "kernel32.dll" ALIAS "GetConsoleScreenBufferInfo" ( BYVAL hConsoleOutput AS QUAD , BYREF lpConsoleScreenBufferInfo AS CONSOLE_SCREEN_BUFFER_INFO ) AS LONG
DECLARE FUNCTION GetConsoleScreenBufferInfoEx LIB "kernel32.dll" ALIAS "GetConsoleScreenBufferInfoEx" ( BYVAL hConsoleOutput AS QUAD
 , BYREF lpConsoleScreenBufferInfoEx AS CONSOLE_SCREEN_BUFFER_INFOEX
 ) AS LONG
DECLARE FUNCTION SetConsoleScreenBufferInfo LIB "kernel32.dll" ALIAS "SetConsoleScreenBufferInfo" ( BYVAL hConsoleOutput AS DWORD
 , BYREF lpConsoleScreenBufferInfoEx AS CONSOLE_SCREEN_BUFFER_INFO
 ) AS LONG
DECLARE FUNCTION GetLargestConsoleWindowSize LIB "kernel32.dll" ALIAS "GetLargestConsoleWindowSize" ( BYVAL hConsoleOutput AS DWORD
 ) AS DWORD ' COORD
DECLARE FUNCTION GetConsoleCursorInfo LIB "kernel32.dll" ALIAS "GetConsoleCursorInfo" ( BYVAL hConsoleOutput AS QUAD , BYREF lpConsoleCursorInfo AS CONSOLE_CURSOR_INFO ) AS LONG
'#if(_WIN32_WINNT >= 0x0500)
DECLARE FUNCTION GetCurrentConsoleFont LIB "kernel32.dll" ALIAS "GetCurrentConsoleFont" ( BYVAL hConsoleOutput AS QUAD , BYVAL bMaximumWindow AS LONG , BYREF lpConsoleCurrentFont AS CONSOLE_FONT_INFO ) AS LONG
#IF NOT %DEF(%NOGDI)
DECLARE FUNCTION GetCurrentConsoleFontEx LIB "kernel32.dll" ALIAS "GetCurrentConsoleFontEx" ( BYVAL hConsoleOutput AS QUAD , BYVAL bMaximumWindow AS LONG , BYREF lpConsoleCurrentFontEx AS CONSOLE_FONT_INFOEX ) AS LONG
DECLARE FUNCTION SetCurrentConsoleFontEx LIB "kernel32.dll" ALIAS "SetCurrentConsoleFontEx" ( BYVAL hConsoleOutput AS QUAD
 , BYVAL bMaximumWindow AS LONG
 , BYREF lpConsoleCurrentFontEx AS CONSOLE_FONT_INFOEX
 ) AS LONG
#ENDIF
DECLARE FUNCTION GetConsoleHistoryInfo LIB "kernel32.dll" ALIAS "GetConsoleHistoryInfo" ( BYREF lpConsoleHistoryInfo AS CONSOLE_HISTORY_INFO ) AS LONG
DECLARE FUNCTION SetConsoleHistoryInfo LIB "kernel32.dll" ALIAS "SetConsoleHistoryInfo" ( BYREF lpConsoleHistoryInfo AS CONSOLE_HISTORY_INFO
 ) AS LONG
DECLARE FUNCTION GetConsoleFontSize LIB "kernel32.dll" ALIAS "GetConsoleFontSize" ( BYVAL hConsoleOutput AS DWORD
 , BYVAL nFont AS DWORD
 ) AS DWORD ' COORD
DECLARE FUNCTION GetConsoleSelectionInfo LIB "kernel32.dll" ALIAS "GetConsoleSelectionInfo" ( BYREF lpConsoleSelectionInfo AS CONSOLE_SELECTION_INFO ) AS LONG
'#endif /* _WIN32_WINNT >= 0x0500 */
DECLARE FUNCTION GetNumberOfConsoleMouseButtons LIB "kernel32.dll" ALIAS "GetNumberOfConsoleMouseButtons" ( BYREF lpNumberOfMouseButtons AS QUAD ) AS LONG
DECLARE FUNCTION SetConsoleMode LIB "kernel32.dll" ALIAS "SetConsoleMode" ( BYVAL hConsoleHandle AS QUAD
 , BYVAL dwMode AS DWORD
 ) AS LONG
DECLARE FUNCTION SetConsoleActiveScreenBuffer LIB "kernel32.dll" ALIAS "SetConsoleActiveScreenBuffer" ( BYVAL hConsoleOutput AS DWORD
 ) AS LONG
DECLARE FUNCTION FlushConsoleInputBuffer LIB "kernel32.dll" ALIAS "FlushConsoleInputBuffer" ( BYVAL hConsoleInput AS DWORD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetConsoleScreenBufferSize LIB "KERNEL32.dll" ALIAS "SetConsoleScreenBufferSize" (BYVAL hConsoleOutput AS QUAD, BYVAL dwSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SetConsoleScreenBufferSize LIB "kernel32.dll" ALIAS "SetConsoleScreenBufferSize" ( BYVAL hConsoleOutput AS QUAD , BYVAL dwSize AS COORD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetConsoleCursorPosition LIB "KERNEL32.dll" ALIAS "SetConsoleCursorPosition" (BYVAL hConsoleOutput AS QUAD, BYVAL dwCursorPosition AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SetConsoleCursorPosition LIB "kernel32.dll" ALIAS "SetConsoleCursorPosition" ( BYVAL hConsoleOutput AS QUAD , BYVAL dwCursorPosition AS COORD ) AS LONG
#ENDIF
DECLARE FUNCTION SetConsoleCursorInfo LIB "kernel32.dll" ALIAS "SetConsoleCursorInfo" ( BYVAL hConsoleOutput AS QUAD , BYREF lpConsoleCursorInfo AS CONSOLE_CURSOR_INFO ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ScrollConsoleScreenBufferA LIB "KERNEL32.dll" ALIAS "ScrollConsoleScreenBufferA" (BYVAL hConsoleOutput AS QUAD, lpScrollRectangle AS SMALL_RECT, lpClipRectangle AS SMALL_RECT, BYVAL dwDestinationOrigin AS QUAD, lpFill AS CHAR_INFO) AS LONG
#ELSE
DECLARE FUNCTION ScrollConsoleScreenBufferA LIB "kernel32.dll" ALIAS "ScrollConsoleScreenBufferA" ( BYVAL hConsoleOutput AS QUAD , BYREF lpScrollRectangle AS SMALL_RECT , BYREF lpClipRectangle AS SMALL_RECT , BYVAL dwDestinationOrigin AS COORD , BYREF lpFill AS CHAR_INFO ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ScrollConsoleScreenBufferW LIB "KERNEL32.dll" ALIAS "ScrollConsoleScreenBufferW" (BYVAL hConsoleOutput AS QUAD, lpScrollRectangle AS SMALL_RECT, lpClipRectangle AS SMALL_RECT, BYVAL dwDestinationOrigin AS QUAD, lpFill AS CHAR_INFO) AS LONG
#ELSE
DECLARE FUNCTION ScrollConsoleScreenBufferW LIB "kernel32.dll" ALIAS "ScrollConsoleScreenBufferW" ( BYVAL hConsoleOutput AS QUAD , BYREF lpScrollRectangle AS SMALL_RECT , BYREF lpClipRectangle AS SMALL_RECT , BYVAL dwDestinationOrigin AS COORD , BYREF lpFill AS CHAR_INFO ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ScrollConsoleScreenBuffer = ScrollConsoleScreenBufferW
#ELSE
 MACRO ScrollConsoleScreenBuffer = ScrollConsoleScreenBufferA
#ENDIF
DECLARE FUNCTION SetConsoleWindowInfo LIB "kernel32.dll" ALIAS "SetConsoleWindowInfo" ( BYVAL hConsoleOutput AS QUAD , BYVAL bAbsolute AS LONG , BYREF lpConsoleWindow AS SMALL_RECT ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetConsoleTextAttribute LIB "KERNEL32.dll" ALIAS "SetConsoleTextAttribute" (BYVAL hConsoleOutput AS QUAD, BYVAL dwAttributes AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SetConsoleTextAttribute LIB "kernel32.dll" ALIAS "SetConsoleTextAttribute" ( BYVAL hConsoleOutput AS QUAD , BYVAL wAttributes AS WORD ) AS LONG
#ENDIF
DECLARE FUNCTION SetConsoleCtrlHandler LIB "kernel32.dll" ALIAS "SetConsoleCtrlHandler" ( BYVAL HandlerRoutine AS QUAD , BYVAL Add AS LONG ) AS LONG
DECLARE FUNCTION GenerateConsoleCtrlEvent LIB "kernel32.dll" ALIAS "GenerateConsoleCtrlEvent" ( BYVAL dwCtrlEvent AS QUAD
 , BYVAL dwProcessGroupId AS DWORD
 ) AS LONG
DECLARE FUNCTION AllocConsole LIB "kernel32.dll" ALIAS "AllocConsole" ( ) AS LONG
DECLARE FUNCTION FreeConsole LIB "kernel32.dll" ALIAS "FreeConsole" ( ) AS LONG
'#if(_WIN32_WINNT >= 0x0500)
DECLARE FUNCTION AttachConsole LIB "kernel32.dll" ALIAS "AttachConsole" ( BYVAL dwProcessId AS QUAD ) AS LONG
%EQUATE `ATTACH_PARENT_PROCESS = &HFFFFFFFF ' ((DWORD)-1)
'#endif /* _WIN32_WINNT >= 0x0500 */
DECLARE FUNCTION GetConsoleTitleA LIB "kernel32.dll" ALIAS "GetConsoleTitleA" ( BYREF lpConsoleTitle AS ASCIIZ , BYVAL nSize AS QUAD ) AS QUAD
DECLARE FUNCTION GetConsoleTitleW LIB "kernel32.dll" ALIAS "GetConsoleTitleW" ( BYREF lpConsoleTitle AS WSTRINGZ
 , BYVAL nSize AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetConsoleTitle = GetConsoleTitleW
#ELSE
 MACRO GetConsoleTitle = GetConsoleTitleA
#ENDIF
'#if(_WIN32_WINNT >= 0x0600)
DECLARE FUNCTION GetConsoleOriginalTitleA LIB "kernel32.dll" ALIAS "GetConsoleOriginalTitleA" ( BYREF lpConsoleTitle AS ASCIIZ , BYVAL nSize AS QUAD ) AS QUAD
DECLARE FUNCTION GetConsoleOriginalTitleW LIB "kernel32.dll" ALIAS "GetConsoleOriginalTitleW" ( BYREF lpConsoleTitle AS WSTRINGZ
 , BYVAL nSize AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetConsoleOriginalTitle = GetConsoleOriginalTitleW
#ELSE
 MACRO GetConsoleOriginalTitle = GetConsoleOriginalTitleA
#ENDIF
'#endif /* _WIN32_WINNT >= 0x0600 */
DECLARE FUNCTION SetConsoleTitleA LIB "kernel32.dll" ALIAS "SetConsoleTitleA" ( BYREF lpConsoleTitle AS ASCIIZ ) AS LONG
DECLARE FUNCTION SetConsoleTitleW LIB "kernel32.dll" ALIAS "SetConsoleTitleW" ( BYREF lpConsoleTitle AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetConsoleTitle = SetConsoleTitleW
#ELSE
 MACRO SetConsoleTitle = SetConsoleTitleA
#ENDIF
' // Size = 16 bytes
TYPE CONSOLE_READCONSOLE_CONTROL DWORD
 nLength AS DWORD
 nInitialChars AS DWORD
 dwCtrlWakeupMask AS DWORD
 dwControlKeyState AS DWORD
END TYPE
DECLARE FUNCTION ReadConsoleA LIB "kernel32.dll" ALIAS "ReadConsoleA" ( BYVAL hConsoleInput AS QUAD , BYREF lpBuffer AS ANY , BYVAL nNumberOfCharsToRead AS QUAD , BYREF lpNumberOfCharsRead AS QUAD , BYREF pInputControl AS ANY ) AS LONG
DECLARE FUNCTION ReadConsoleW LIB "kernel32.dll" ALIAS "ReadConsoleW" ( BYVAL hConsoleInput AS QUAD
 , BYREF lpBuffer AS ANY
 , BYVAL nNumberOfCharsToRead AS DWORD
 , BYREF lpNumberOfCharsRead AS DWORD
 , BYREF pInputControl AS ANY
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO ReadConsole = ReadConsoleW
#ELSE
 MACRO ReadConsole = ReadConsoleA
#ENDIF
DECLARE FUNCTION WriteConsoleA LIB "kernel32.dll" ALIAS "WriteConsoleA" ( BYVAL hConsoleOutput AS QUAD , BYREF lpBuffer AS ASCIIZ , BYVAL nNumberOfCharsToWrite AS QUAD , BYREF lpNumberOfCharsWritten AS QUAD , BYVAL lpReserved AS QUAD ) AS LONG
DECLARE FUNCTION WriteConsoleW LIB "kernel32.dll" ALIAS "WriteConsoleW" ( BYVAL hConsoleOutput AS QUAD
 , BYREF lpBuffer AS WSTRINGZ
 , BYVAL nNumberOfCharsToWrite AS DWORD
 , BYREF lpNumberOfCharsWritten AS DWORD
 , BYVAL lpReserved AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO WriteConsole = WriteConsoleW
#ELSE
 MACRO WriteConsole = WriteConsoleA
#ENDIF
%EQUATE `CONSOLE_TEXTMODE_BUFFER = 1
DECLARE FUNCTION CreateConsoleScreenBuffer LIB "kernel32.dll" ALIAS "CreateConsoleScreenBuffer" ( BYVAL dwDesiredAccess AS QUAD , BYVAL dwShareMode AS QUAD , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYVAL dwFlags AS QUAD , BYVAL lpScreenBufferData AS QUAD ) AS QUAD
DECLARE FUNCTION GetConsoleCP LIB "kernel32.dll" ALIAS "GetConsoleCP" ( ) AS QUAD ' UINT
DECLARE FUNCTION SetConsoleCP LIB "kernel32.dll" ALIAS "SetConsoleCP" ( BYVAL wCodePageID AS QUAD ) AS LONG
DECLARE FUNCTION GetConsoleOutputCP LIB "kernel32.dll" ALIAS "GetConsoleOutputCP" ( ) AS QUAD ' UINT
DECLARE FUNCTION SetConsoleOutputCP LIB "kernel32.dll" ALIAS "SetConsoleOutputCP" ( BYVAL wCodePageID AS QUAD ) AS LONG
'#if(_WIN32_WINNT >= 0x0500)
%EQUATE `CONSOLE_FULLSCREEN = 1 ' // fullscreen console
%EQUATE `CONSOLE_FULLSCREEN_HARDWARE = 2 ' // console owns the hardware
DECLARE FUNCTION GetConsoleDisplayMode LIB "kernel32.dll" ALIAS "GetConsoleDisplayMode" ( BYREF lpModeFlags AS QUAD ) AS LONG
%EQUATE `CONSOLE_FULLSCREEN_MODE = 1
%EQUATE `CONSOLE_WINDOWED_MODE = 2
DECLARE FUNCTION SetConsoleDisplayMode LIB "kernel32.dll" ALIAS "SetConsoleDisplayMode" ( BYVAL hConsoleOutput AS QUAD , BYVAL dwFlags AS QUAD , BYREF lpNewScreenBufferDimensions AS COORD ) AS LONG
DECLARE FUNCTION GetConsoleWindow LIB "kernel32.dll" ALIAS "GetConsoleWindow" ( ) AS QUAD
'#endif /* _WIN32_WINNT >= 0x0500 */
'#if(_WIN32_WINNT >= 0x0501)
DECLARE FUNCTION GetConsoleProcessList LIB "kernel32.dll" ALIAS "GetConsoleProcessList" ( BYREF lpdwProcessList AS QUAD , BYVAL dwProcessCount AS QUAD ) AS QUAD
'//
'// Aliasing apis.
'//
DECLARE FUNCTION AddConsoleAliasA LIB "kernel32.dll" ALIAS "AddConsoleAliasA" ( BYREF Source AS ASCIIZ , BYREF Target AS ASCIIZ , BYREF ExeName AS ASCIIZ ) AS LONG
DECLARE FUNCTION AddConsoleAliasW LIB "kernel32.dll" ALIAS "AddConsoleAliasW" ( BYREF Source AS WSTRINGZ
 , BYREF Target AS WSTRINGZ
 , BYREF ExeName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO AddConsoleAlias = AddConsoleAliasW
#ELSE
 MACRO AddConsoleAlias = AddConsoleAliasA
#ENDIF
DECLARE FUNCTION GetConsoleAliasA LIB "kernel32.dll" ALIAS "GetConsoleAliasA" ( BYREF Source AS ASCIIZ , BYREF TargetBuffer AS ASCIIZ , BYVAL TargetBufferLength AS QUAD , BYREF ExeName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION GetConsoleAliasW LIB "kernel32.dll" ALIAS "GetConsoleAliasW" ( BYREF Source AS WSTRINGZ
 , BYREF TargetBuffer AS WSTRINGZ
 , BYVAL TargetBufferLength AS DWORD
 , BYREF ExeName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetConsoleAlias = GetConsoleAliasW
#ELSE
 MACRO GetConsoleAlias = GetConsoleAliasA
#ENDIF
DECLARE FUNCTION GetConsoleAliasesLengthA LIB "kernel32.dll" ALIAS "GetConsoleAliasesLengthA" ( BYREF ExeName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION GetConsoleAliasesLengthW LIB "kernel32.dll" ALIAS "GetConsoleAliasesLengthW" ( BYREF ExeName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetConsoleAliasesLength = GetConsoleAliasesLengthW
#ELSE
 MACRO GetConsoleAliasesLength = GetConsoleAliasesLengthA
#ENDIF
DECLARE FUNCTION GetConsoleAliasExesLengthA LIB "kernel32.dll" ALIAS "GetConsoleAliasExesLengthA" ( ) AS QUAD
DECLARE FUNCTION GetConsoleAliasExesLengthW LIB "kernel32.dll" ALIAS "GetConsoleAliasExesLengthW" ( ) AS QUAD
#IF %DEF(%UNICODE)
 MACRO GetConsoleAliasExesLength = GetConsoleAliasExesLengthW
#ELSE
 MACRO GetConsoleAliasExesLength = GetConsoleAliasExesLengthA
#ENDIF
' PB declare
'DECLARE FUNCTION GetConsoleAliasesA LIB "Kernel32.dll" ' ALIAS "GetConsoleAliasesA" (BYVAL AliasBuffer AS DWORD, ' BYVAL AliasBufferLength AS DWORD, ExeName AS ASCIIZ) AS DWORD
DECLARE FUNCTION GetConsoleAliasesA LIB "kernel32.dll" ALIAS "GetConsoleAliasesA" ( BYREF AliasBuffer AS ASCIIZ , BYVAL AliasBufferLength AS QUAD , BYREF ExeName AS ASCIIZ ) AS QUAD
' PB declare
'DECLARE FUNCTION GetConsoleAliasesW LIB "Kernel32.dll" ' ALIAS "GetConsoleAliasesW" (BYVAL AliasBuffer AS DWORD, ' BYVAL AliasBufferLength AS DWORD, ExeName AS WSTRINGZ) AS DWORD
DECLARE FUNCTION GetConsoleAliasesW LIB "kernel32.dll" ALIAS "GetConsoleAliasesW" ( BYREF AliasBuffer AS WSTRINGZ , BYVAL AliasBufferLength AS QUAD , BYREF ExeName AS WSTRINGZ ) AS QUAD
#IF %DEF(%UNICODE)
 MACRO GetConsoleAliases = GetConsoleAliasesW
#ELSE
 MACRO GetConsoleAliases = GetConsoleAliasesA
#ENDIF
DECLARE FUNCTION GetConsoleAliasExesA LIB "kernel32.dll" ALIAS "GetConsoleAliasExesA" ( BYREF ExeNameBuffer AS ASCIIZ , BYVAL ExeNameBufferLength AS QUAD ) AS QUAD
DECLARE FUNCTION GetConsoleAliasExesW LIB "kernel32.dll" ALIAS "GetConsoleAliasExesW" ( BYREF ExeNameBuffer AS WSTRINGZ
 , BYVAL ExeNameBufferLength AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetConsoleAliasExes = GetConsoleAliasExesW
#ELSE
 MACRO GetConsoleAliasExes = GetConsoleAliasExesA
#ENDIF
#ENDIF
