How to get the current video mode in console?

Hi, I've been wondering if there's a function or procedure used to know the current video mode. An example of how this was done in Pascal:

1
2
3
4
5
6
7
function VideoMode : integer;
begin
     if (lastmode = BW40) or (lastmode = BW80)
        VideoMode := 40
     else
         VideoMode := 80;
end;


I've been told "conio.h" has a lastmode function, but it doesn't seem to be supported in Dev-C++ and Visual Studio C++. Is there a Windows function to know the number of columns in the current video mode? Thank you.
This really belongs in the Windows forum.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <Windows.h>

int main()
{
    if (HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE))
    {
        CONSOLE_SCREEN_BUFFER_INFO info;
        if (GetConsoleScreenBufferInfo(out, &info))
            std::cout << "Columns: " << info.dwSize.X << '\n';
        else
            std::cerr << "Unable to determine size.\n";
    }
}


For a more useful example see: http://www.cplusplus.com/forum/windows/121444/#msg661553
Last edited on
Topic archived. No new replies allowed.