1

I'm trying to get every screen resolution (ex : 1920x1080) and zoom factor (ex : 125% or 120 dpi), without needing to move the application from screen to screen.

I've tried a lot of class/methods, but none gave me the correct result for my setup (Windows 10, primary screen is 1920x1080 zoom 125% and secondary screen (on the right) is 1920x1080 zoom 100%).

System.Windows.Forms.Screen gives those results : - 1920x1080 resolution for 1st screen (ok) - 2400x1350 resolution for 2nd screen (not ok, should be 1920x1080)

Same results with http://www.wpftutorial.net/ScreenResolutions.html

With PInvoke, shcore.dll's GetDpiForMonitor() gives those results : - 120 for 1st screen (ok) - 120 for 2nd screen (not ok, should be 96)

Do you have any idea how I can do that and have correct results?

krimog
  • 1,257
  • 11
  • 25

1 Answers1

1

I found a solution: in the registry, the resolution is correct.

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware Profiles\*\CONTROL\VIDEO\*\*

In there, you can find your current screens with Attach.ToDesktop = 1. Then, you can use DefaultSettings.XResolution, DefaultSettings.YResolution, Attach.RelativeX and Attach.RelativeY to find screen resolutions and positionning.

To find the zoom factor, either use GetDpiForMonitor() if the resolution from registry is the same as the resolution from System.Windows.Forms.Screen or get the ratio from both and multiply it by 96.

krimog
  • 1,257
  • 11
  • 25