I found this code, but I wanted to ask a fast question, does this give the maximum possible resolution? Or just the current resolution set? I know there is a System function but I am trying not to use any System functions if at all possible.

#include "wtypes.h"
#include <iostream>
using namespace std;

// Get the horizontal and vertical screen sizes in pixel
void GetDesktopResolution(int& horizontal, int& vertical)
   RECT desktop;
   // Get a handle to the desktop window
   const HWND hDesktop = GetDesktopWindow();
   // Get the size of screen to the variable desktop
   GetWindowRect(hDesktop, &desktop);
   // The top left corner will have coordinates (0,0)
   // and the bottom right corner will have coordinates
   // (horizontal, vertical)
   horizontal = desktop.right;
   vertical = desktop.bottom;

int main()
   int horizontal = 0;
   int vertical = 0;
   GetDesktopResolution(horizontal, vertical);
   cout << horizontal << '\n' << vertical << '\n';
   return 0;

Yeah, umm, I need C++ code :) I know how to do it in C# already, trying to do it in C++ without using the System namespace.

Member Avatar

I don't know of a way around that unless you use the System namespace, but I've never experimented with finding an alternative method.

Oof, wrong forum...

But, I was looking at EnumDisplaySettings; however, that appears to be in System...

Well, the same site as my last (erroneous) link has a C++ example, but it's probably no good to you, since it's using System namespace functions:


Sorry I couldn't be of any help.

Ty for trying, if there is no alternative besides the System I guess I will have to use it.