Console v0.1.0
WriteConsoleW
pub extern func WriteConsoleW(
consoleOutput: *var opaque,
buffer: *opaque,
numberOfCharsToWrite: uint32,
numberOfCharsWritten: *var uint32,
reserved: *var opaque
) -> int32
pub extern func WriteConsoleW(
consoleOutput: *opaque,
buffer: *char16,
numberOfCharsToWrite: uint32,
numberOfCharsWritten: *uint32,
reserved: *opaque
) -> bool32
Writes a character string to a console screen buffer beginning at the current cursor location.
| Overload | Summary |
|---|---|
pub extern func WriteConsoleW(consoleOutput: *var opaque, buffer: *opaque, numberOfCharsToWrite: uint32, numberOfCharsWritten: *var uint32, reserved: *var opaque) -> int32 | Writes UTF-16 to a console screen buffer. |
pub extern func WriteConsoleW(consoleOutput: *opaque, buffer: *char16, numberOfCharsToWrite: uint32, numberOfCharsWritten: *uint32, reserved: *opaque) -> bool32 | Writes a character string to a console screen buffer beginning at the current cursor location. |
See also: https://learn.microsoft.com/en-us/windows/console/writeconsole
Parameters
| Name | Type | Description |
|---|---|---|
consoleOutput | *var opaque / *opaque | a console output handle |
buffer | *opaque / *char16 | the bytes |
numberOfCharsToWrite | uint32 | how many units to write |
numberOfCharsWritten | *var uint32 / *uint32 | receives how many were written |
reserved | *var opaque / *opaque | reserved; pass null |
Returns: non-zero on success, and zero on failure with the reason in GetLastError
ReadConsoleW
pub extern func ReadConsoleW(
consoleInput: *var opaque,
buffer: *var opaque,
numberOfCharsToRead: uint32,
numberOfCharsRead: *var uint32,
inputControl: *var opaque
) -> int32
Reads UTF-16 from a console input buffer.
See also: https://learn.microsoft.com/en-us/windows/console/readconsole
Parameters
| Name | Type | Description |
|---|---|---|
consoleInput | *var opaque | a console input handle |
buffer | *var opaque | the bytes |
numberOfCharsToRead | uint32 | how many units to ask for |
numberOfCharsRead | *var uint32 | receives how many were read |
inputControl | *var opaque | an input-control record, or null |
Returns: non-zero on success
AllocConsole
pub extern func AllocConsole() -> bool32
Allocates a new console for the calling process.
See also: https://learn.microsoft.com/en-us/windows/console/allocconsole
Returns: non-zero on success, and zero on failure with the reason in GetLastError
Beep
pub extern func Beep(
freq: uint32,
duration: uint32
) -> bool32
Generates simple tones on the speaker.
See also: https://learn.microsoft.com/en-us/windows/win32/api/utilapiset/nf-utilapiset-beep
Parameters
| Name | Type | Description |
|---|---|---|
freq | uint32 | the tone's frequency in hertz |
duration | uint32 | how long to sound it, in milliseconds |
Returns: non-zero on success, and zero on failure with the reason in GetLastError
GetConsoleMode
pub extern func GetConsoleMode(
consoleHandle: *opaque,
mode: *uint32
) -> bool32
Retrieves the current input or output mode of a console screen buffer.
See also: https://learn.microsoft.com/en-us/windows/console/getconsolemode
Parameters
| Name | Type | Description |
|---|---|---|
consoleHandle | *opaque | a console handle |
mode | *uint32 | receives the console mode bits |
Returns: non-zero on success, and zero on failure with the reason in GetLastError
GetStdHandle
pub extern func GetStdHandle(stdHandle: uint32) -> *opaque
Retrieves a handle to the specified standard device (standard input, standard output, or standard error).
See also: https://learn.microsoft.com/en-us/windows/console/getstdhandle
Parameters
| Name | Type | Description |
|---|---|---|
stdHandle | uint32 | one of StdInputHandle, StdOutputHandle or StdErrorHandle |
Returns: the standard handle, or InvalidHandleValue
ReadConsoleA
pub extern func ReadConsoleA(
consoleInput: *opaque,
buffer: *opaque,
numberOfCharsToRead: uint32,
numberOfCharsRead: *uint32,
inputControl: *opaque
) -> bool32
Reads characters from a console input buffer.
See also: https://learn.microsoft.com/en-us/windows/console/readconsole
Parameters
| Name | Type | Description |
|---|---|---|
consoleInput | *opaque | a console input handle |
buffer | *opaque | the bytes |
numberOfCharsToRead | uint32 | how many units to ask for |
numberOfCharsRead | *uint32 | receives how many were read |
inputControl | *opaque | an input-control record, or null |
Returns: non-zero on success, and zero on failure with the reason in GetLastError
WriteConsoleA
pub extern func WriteConsoleA(
consoleOutput: *opaque,
buffer: *char8,
numberOfCharsToWrite: uint32,
numberOfCharsWritten: *uint32,
reserved: *opaque
) -> bool32
Writes a character string to a console screen buffer beginning at the current cursor location.
See also: https://learn.microsoft.com/en-us/windows/console/writeconsole
Parameters
| Name | Type | Description |
|---|---|---|
consoleOutput | *opaque | a console output handle |
buffer | *char8 | the bytes |
numberOfCharsToWrite | uint32 | how many units to write |
numberOfCharsWritten | *uint32 | receives how many were written |
reserved | *opaque | reserved; pass null |
Returns: non-zero on success, and zero on failure with the reason in GetLastError
StdInputHandle
pub const StdInputHandle: uint32 = 0xFFFFFFF6;
The public StdInputHandle value.
StdOutputHandle
pub const StdOutputHandle: uint32 = 0xFFFFFFF5;
The public StdOutputHandle value.
StdErrorHandle
pub const StdErrorHandle: uint32 = 0xFFFFFFF4;
The public StdErrorHandle value.