Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

GetConsoleScreenBufferInfo (kernel32)
 
.
Summary
TODO - a short description
Summary

C# Signature:

    [DllImport("kernel32.dll", SetLastError = true)]
    static extern bool GetConsoleScreenBufferInfoEx(
        IntPtr hConsoleOutput,
        ref CONSOLE_SCREEN_BUFFER_INFO_EX ConsoleScreenBufferInfo
        );

VB Signature:

Declare Function GetConsoleScreenBufferInfoEx Lib "kernel32.dll" (TODO) As TODO
[DllImport("kernel32.dll")]
static extern bool GetConsoleScreenBufferInfo(IntPtr hConsoleOutput,
   out CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);

User-Defined Types:

    [StructLayout(LayoutKind.Sequential)]
    public struct CONSOLE_SCREEN_BUFFER_INFO_EX
    {
        public uint cbSize;
        public COORD dwSize;
        public COORD dwCursorPosition;
        public short wAttributes;
        public SMALL_RECT srWindow;
        public COORD dwMaximumWindowSize;

public struct COORD

{

  public short X;
  public short Y;

}

public struct SMALL_RECT

{

  public short Left;
  public short Top;
  public short Right;
  public short Bottom;

}

public struct CONSOLE_SCREEN_BUFFER_INFO

{

public COORD dwSize;
public COORD dwCursorPosition;
public short  wAttributes;
public SMALL_RECT srWindow;
public COORD dwMaximumWindowSize;

}

Notes:

None.

        public ushort wPopupAttributes;
        public bool bFullscreenSupported;

Tips & Tricks:

Please add some!

Sample Code:

public static bool GetConsoleWindowSize ( out int cchWidth, out int cchHeight )

{

  cchWidth = -1;
  cchHeight = -1;
  const int STD_OUTPUT_HANDLE = -11;

  CONSOLE_SCREEN_BUFFER_INFO csbi;
  if ( GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), out csbi ) )
  {
    cchWidth = csbi.dwSize.X;
    cchHeight = csbi.dwSize.Y;
    return true;
  }
  return false;

}

        internal COLORREF black;
        internal COLORREF darkBlue;
        internal COLORREF darkGreen;
        internal COLORREF darkCyan;
        internal COLORREF darkRed;
        internal COLORREF darkMagenta;
        internal COLORREF darkYellow;
        internal COLORREF gray;
        internal COLORREF darkGray;
        internal COLORREF blue;
        internal COLORREF green;
        internal COLORREF cyan;
        internal COLORREF red;
        internal COLORREF magenta;
        internal COLORREF yellow;
        internal COLORREF white;

        // has been a while since I did this, test before use
        // but should be something like:
        //
        // [MarshalAs(UnmanagedType.ByValArray, SizeConst=16)]
        // public COLORREF[] ColorTable;
    }

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

cbSize must be initialized - ConsoleScreenBufferInfo.cbSize = (uint)sizeof(CONSOLE_SCREEN_BUFFER_INFO_EX);

Documentation

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions