Get screen resolution in Windows 8 Metro style application

July 24, 2012

Today, someone asked an interesting question in the Israeli Metro forum I’m moderating.

The question was: “How can I know what’s the screen resolution in a Metro style app?”

This is a tricky answer, since:

  1. This capability has been removed from the RC.
  2. We can’t rely on current window Width and Height, since it may not be fully opened (snapping).

Well, searching a bit over the API’s, I didn’t find anything that can help, but, we can always use DirectX.

Creating a C++ Metro style application, here’s a code snippet demonstrating how to extract the screen resolution of a given display device:



Using DirectX, we can query for the IDXGIAdapter, then make a call the EnumOutputs, which provides information for output devices. From there, we can make a call for IDXGIOutput::GetDesc to get the device description. From there we can extract the screen resolution.

Now, to be able getting this value from a C# or JS application, we should create a simple WinRT object, placing it in a WinRT dll, then use it from other projects.

To create a WinRT object with C++, we should create a class which looks like this:



Feel free to download the code ( for both the WinRT object and a C# tester.

Running the application, you can click on the Button and see your screen resolution. Changing the resolution and click the button again, you may see it updated.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



  1. meeraOctober 18, 2012 ב 08:37

    How to get screen size in inches for windows 8 app? Please do reply.

  2. meeraOctober 18, 2012 ב 08:37

    How to get screen size in inches for windows 8 app? Please do reply.

  3. Emmanuel HunaFebruary 21, 2013 ב 01:20

    Since the C++ project needs Win32, the TestApp can only be compiled in x86. Does this mean that if we use this that the app cannot work on ARM, so it won’t work on the Surface RT?

  4. Tomer ShamamApril 24, 2013 ב 01:42

    No. It supposed to work with all builds.