Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting all supported screen resolutions

I'm looking for a way to get all supported resolutions.

After searching here for some solutions I got this code working:

#include "Windows.h"
#include <Windows.h>
#include <iostream>


using namespace std;

int main()
{
    DEVMODE dm = { 0 };
    dm.dmSize = sizeof(dm);
    for( int iModeNum = 0; EnumDisplaySettings( NULL, iModeNum, &dm ) != 0; iModeNum++      ) 
    {
       cout << "Mode #" << iModeNum << " = " << dm.dmPelsWidth << "x" << dm.dmPelsHeight << endl;
     }
 int age;
 cin>>age;

}

I have 2 problems with this code:

  1. When running it, I get the same resolution over and over again. For example : Mode0, Mode1, Mode2..... Mode17 are all : 320x200

  2. When using the Gui and looking at the available resolutions, I don't have 320x200 as an option . I see that my computer supports 600x800 and upper, but when running this small exe I also see 400x300, 320x240 etc..

Can anyone help and advise please? Thanks!

like image 374
user1386966 Avatar asked Feb 24 '26 10:02

user1386966


1 Answers

Your code is working perfectly. Regarding your 2 problems:

  1. There are multiple display modes that have the same resolution. They may differ in other ways such as color depth, frequency, or interlacing.
  2. The Windows GUI simply never allows you to set resolutions or color depths below a certain amount. With Windows '9x it was 640x480 and 16 colors. Now it is 800x600. This is simply because the Windows UI doesn't work below a certain size. You wouldn't even be able to see the message asking if the resolution worked! Also, the GUI may only return resolutions that match the aspect ratio of your monitor.

EDIT: By "frequency" we mean "refresh rate"

like image 146
Moby Disk Avatar answered Feb 27 '26 00:02

Moby Disk