question

StevenYoung-5410 avatar image
0 Votes"
StevenYoung-5410 asked Castorix31 answered

How to get Windows 10 display scaling value using C# (Note: not the DPI value)

In the display settings of Windows 10, you can set the scaling ratio (for example: 125%, 150%). Please note that it is not the DPI value. How to get this value using C#.

dotnet-csharpwindows-10-generalwindows-forms
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Have you got any chance to check the previous comment: https://docs.microsoft.com/en-us/answers/questions/402933/?


0 Votes 0 ·

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered MichaelTarrant-6992 commented

For example with GetDpiForWindow

with a Manifest to get right results:

    <application xmlns="urn:schemas-microsoft-com:asm.v3">
      <windowsSettings>
        <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
        <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor</dpiAwareness>
       </windowsSettings>
    </application>

I get :
96 for 100%
120 for 125%
144 for 150%
etc...


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.