public static extern bool SetConsoleMode(SafeConsoleHandle hConsoleHandle, ConsoleMode dwMode);
public static extern bool GetConsoleMode(SafeConsoleHandle hConsoleHandle, out ConsoleMode lpMode);
public static extern bool SetConsoleDisplayMode( SafeConsoleHandle hConsoleOutput, ConsoleDisplayMode dwFlags, out Coord lpNewScreenBufferDimensions);
public static extern bool GetNumberOfConsoleInputEvents( SafeConsoleHandle hConsoleInput, out uint lpcNumberOfEvents);
/// <summary> /// Retrieves extended information about the current console font. /// </summary> /// <param name="hConsoleOutput"> /// [in] A handle to the console screen buffer. The handle must have the GENERIC_READ access right. /// </param> /// <param name="bMaximumWindow"> /// [in] If this parameter is <c>TRUE</c>, font information is retrieved for the maximum window size. If this /// parameter is <c>FALSE</c>, font information is retrieved for the current window size. /// </param> /// <returns> /// A <see cref="ConsoleFontInfoEx"/> structure that receives the requested font information. /// </returns> public static ConsoleFontInfoEx GetCurrentConsoleFontEx(SafeConsoleHandle hConsoleOutput, bool bMaximumWindow) { var lpConsoleCurrentFontEx = new ConsoleFontInfoEx(); WinError.ThrowLastWin32ErrorIfFailed( GetCurrentConsoleFontEx(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFontEx)); return lpConsoleCurrentFontEx; }
/// <summary> /// Retrieves extended information about the specified console screen buffer. /// </summary> /// <param name="hConsoleOutput"> /// [in] A handle to the console screen buffer. The handle must have the <see cref="ConsoleAccess.GENERIC_READ"/> /// access right. /// </param> /// <returns> /// A <see cref="ConsoleScreenBufferInfoEx"/> structure that receives the requested console screen buffer /// information. /// </returns> public static ConsoleScreenBufferInfoEx GetConsoleScreenBufferInfoEx(SafeConsoleHandle hConsoleOutput) { var lpConsoleScreenBufferInfoEx = new ConsoleScreenBufferInfoEx(); WinError.ThrowLastWin32ErrorIfFailed( GetConsoleScreenBufferInfoEx(hConsoleOutput, lpConsoleScreenBufferInfoEx)); return lpConsoleScreenBufferInfoEx; }
public static extern bool GetConsoleScreenBufferInfo( SafeConsoleHandle hConsoleOutput, [Out] ConsoleScreenBufferInfo lpConsoleScreenBufferInfo);
/// <summary> /// Retrieves information about the size and visibility of the cursor for the specified console screen buffer. /// </summary> /// <param name="hConsoleOutput"> /// [in] A handle to the console screen buffer. The handle must have the <c>GENERIC_READ</c> access right. /// </param> /// <returns> /// A pointer to a <see cref="ConsoleCursorInfo"/> structure that receives information about the console's /// cursor. /// </returns> public static ConsoleCursorInfo GetConsoleCursorInfo(SafeConsoleHandle hConsoleOutput) { var lpConsoleCursorInfo = new ConsoleCursorInfo(); WinError.ThrowLastWin32ErrorIfFailed( GetConsoleCursorInfo(hConsoleOutput, lpConsoleCursorInfo)); return lpConsoleCursorInfo; }
/// <summary> /// Writes a character string to a console screen buffer beginning at the current cursor location. /// </summary> /// <param name="hConsoleOutput"> /// [in] A handle to the console screen buffer. The handle must have the <see cref="ConsoleAccess.GENERIC_WRITE"/> /// access right. /// </param> /// <param name="lpBuffer"> /// [in] A pointer to a buffer that contains characters to be written to the console screen buffer. /// </param> /// <param name="nNumberOfCharsToWrite"> /// [in] The number of characters to be written. If the total size of the specified number of characters /// exceeds the available heap, the function fails with <see cref="ERROR_NOT_ENOUGH_MEMORY"/>. /// </param> /// <returns>The number of characters actually written.</returns> public static uint WriteConsole(SafeConsoleHandle hConsoleOutput, string lpBuffer, uint nNumberOfCharsToWrite) { uint lpNumberOfCharsWritten; WinError.ThrowLastWin32ErrorIfFailed( WriteConsole(hConsoleOutput, lpBuffer, nNumberOfCharsToWrite, out lpNumberOfCharsWritten, IntPtr.Zero)); return lpNumberOfCharsWritten; }
public static extern bool WriteConsole( SafeConsoleHandle hConsoleOutput, string lpBuffer, uint nNumberOfCharsToWrite, out uint lpNumberOfCharsWritten, IntPtr lpReserved);
public static extern bool SetConsoleWindowInfo( SafeConsoleHandle hConsoleOutput, [MarshalAs(UnmanagedType.Bool)] bool bAbsolute, [In] SmallRect lpConsoleWindow);
public static extern bool SetConsoleTextAttribute( SafeConsoleHandle hConsoleOutput, CharacterAttributes wAttributes);
public static extern bool SetConsoleScreenBufferSize(SafeConsoleHandle hConsoleOutput, Coord dwSize);
/// <summary> /// Sets the display mode of the specified console screen buffer. /// </summary> /// <param name="hConsoleOutput"> /// [in] A handle to the console screen buffer. /// </param> /// <param name="dwFlags"> /// [in] The display mode of the console. /// </param> /// <returns> /// A <see cref="Coord"/> structure that receives the new dimensions of the screen buffer, in characters. /// </returns> public static Coord SetConsoleDisplayMode(SafeConsoleHandle hConsoleOutput, ConsoleDisplayMode dwFlags) { Coord lpNewScreenBufferDimensions; WinError.ThrowLastWin32ErrorIfFailed( SetConsoleDisplayMode(hConsoleOutput, dwFlags, out lpNewScreenBufferDimensions)); return lpNewScreenBufferDimensions; }
public static extern bool FlushConsoleInputBuffer(SafeConsoleHandle hConsoleInput);
public static extern bool WriteConsoleInput( SafeConsoleHandle hConsoleInput, InputRecord[] lpBuffer, uint nLength, out uint lpNumberOfEventsWritten);
public static extern bool GetConsoleCursorInfo( SafeConsoleHandle hConsoleOutput, [In, Out] ConsoleCursorInfo lpConsoleCursorInfo);
/// <summary> /// Writes data directly to the console input buffer. /// </summary> /// <param name="hConsoleInput"> /// [in] A handle to the console input buffer. The handle must have the <see cref="ConsoleAccess.GENERIC_WRITE"/> /// access right. /// </param> /// <param name="lpBuffer"> /// [in] A pointer to an array of <see cref="InputRecord"/> structures that contain data to be written to the /// input buffer. /// </param> /// <param name="nLength"> /// [in] The number of input records to be written. /// </param> /// <returns>The number of input records actually written.</returns> public static uint WriteConsoleInput(SafeConsoleHandle hConsoleInput, InputRecord[] lpBuffer, uint nLength) { uint lpNumberOfEventsWritten; WinError.ThrowLastWin32ErrorIfFailed( WriteConsoleInput(hConsoleInput, lpBuffer, nLength, out lpNumberOfEventsWritten)); return lpNumberOfEventsWritten; }
public static extern Coord GetConsoleFontSize(SafeConsoleHandle hConsoleOutput, uint nFont);
public static extern bool WriteConsoleOutput( SafeConsoleHandle hConsoleOutput, CharInfo[] lpBuffer, Coord dwBufferSize, Coord dwBufferCoord, [In, Out] SmallRect lpWriteRegion);
/// <summary> /// Retrieves the current input mode of a console's input buffer or the current output mode of a console /// screen buffer. /// </summary> /// <param name="hConsoleHandle"> /// [in] A handle to the console input buffer or the console screen buffer. The handle must have the /// <c>GENERIC_READ</c> access right. /// </param> /// <returns>The current mode of the specified buffer.</returns> public static ConsoleMode GetConsoleMode(SafeConsoleHandle hConsoleHandle) { ConsoleMode lpMode; WinError.ThrowLastWin32ErrorIfFailed(GetConsoleMode(hConsoleHandle, out lpMode)); return lpMode; }
public static extern bool WriteConsoleOutputAttribute( SafeConsoleHandle hConsoleOutput, CharacterAttributes[] lpAttribute, uint nLength, Coord dwWriteCoord, out uint lpNumberOfAttrsWritten);
public static extern bool GetConsoleScreenBufferInfoEx( SafeConsoleHandle hConsoleOutput, [In, Out] ConsoleScreenBufferInfoEx lpConsoleScreenBufferInfoEx);
/// <summary> /// Copies a number of character attributes to consecutive cells of a console screen buffer, beginning at a /// specified location. /// </summary> /// <param name="hConsoleOutput"> /// [in] A handle to the console screen buffer. The handle must have the <see cref="ConsoleAccess.GENERIC_WRITE"/> /// access right. /// </param> /// <param name="lpAttribute"> /// [in] The attributes to be used when writing to the console screen buffer. /// </param> /// <param name="nLength"> /// [in] The number of screen buffer character cells to which the attributes will be copied. /// </param> /// <param name="dwWriteCoord"> /// [in] A <see cref="Coord"/> structure that specifies the character coordinates of the first cell in the /// console screen buffer to which the attributes will be written. /// </param> /// <returns>The number of attributes actually written to the console screen buffer.</returns> public static uint WriteConsoleOutputAttribute( SafeConsoleHandle hConsoleOutput, CharacterAttributes[] lpAttribute, uint nLength, Coord dwWriteCoord) { uint lpNumberOfAttrsWritten; WinError.ThrowLastWin32ErrorIfFailed( WriteConsoleOutputAttribute(hConsoleOutput, lpAttribute, nLength, dwWriteCoord, out lpNumberOfAttrsWritten)); return lpNumberOfAttrsWritten; }
public static extern bool GetCurrentConsoleFontEx( SafeConsoleHandle hConsoleOutput, [MarshalAs(UnmanagedType.Bool)] bool bMaximumWindow, [In, Out] ConsoleFontInfoEx lpConsoleCurrentFontEx);
public static extern bool FillConsoleOutputCharacter( SafeConsoleHandle hConsoleOutput, char cCharacter, uint nLength, Coord dwWriteCoord, out uint lpNumberOfCharsWritten);
public static extern Coord GetLargestConsoleWindowSize(SafeConsoleHandle hConsoleOutput);
/// <summary> /// Writes a character to the console screen buffer a specified number of times, beginning at the specified /// coordinates. /// </summary> /// <param name="hConsoleOutput"> /// [in] A handle to the console screen buffer. The handle must have the <see cref="ConsoleAccess.GENERIC_WRITE"/> /// access right. /// </param> /// <param name="cCharacter"> /// [in] The character to be written to the console screen buffer. /// </param> /// <param name="nLength"> /// [in] The number of character cells to which the character should be written. /// </param> /// <param name="dwWriteCoord"> /// [in] A <see cref="Coord"/> structure that specifies the character coordinates of the first cell to which /// the character is to be written. /// </param> /// <returns>The number of characters actually written to the console screen buffer.</returns> public static uint FillConsoleOutputCharacter( SafeConsoleHandle hConsoleOutput, char cCharacter, uint nLength, Coord dwWriteCoord) { uint lpNumberOfCharsWritten; WinError.ThrowLastWin32ErrorIfFailed( FillConsoleOutputCharacter(hConsoleOutput, cCharacter, nLength, dwWriteCoord, out lpNumberOfCharsWritten)); return lpNumberOfCharsWritten; }
/// <summary> /// Retrieves the number of unread input records in the console's input buffer. /// </summary> /// <param name="hConsoleInput"> /// [in] A handle to the console input buffer. The handle must have the <c>GENERIC_READ</c> access right. /// </param> /// <returns>The number of unread input records in the console's input buffer.</returns> public static uint GetNumberOfConsoleInputEvents(SafeConsoleHandle hConsoleInput) { uint lpcNumberOfEvents; WinError.ThrowLastWin32ErrorIfFailed(GetNumberOfConsoleInputEvents(hConsoleInput, out lpcNumberOfEvents)); return lpcNumberOfEvents; }
public static extern bool SetConsoleActiveScreenBuffer(SafeConsoleHandle hConsoleOutput);