Read out "Display" of "Appearance and personalization"

797 views Asked by At

I want to read out the value of the "Display"-Setting out of the "Appearance and personalization" in the controlpanel of Windows7 with a C#-App , because prior Startup the app has to check that the value is set in 100% and inform the user if this is not the case.

Here is what control panel I mean: http://maketecheasier.com/change-icon-size-and-display-settings-in-windows-7/2010/01/12

Thank you in advance!

I tried:

1

There are 1 answers

0
Ian Boyd On

You are after the two "dpi" settings in Windows, one in the horizontal direction, and one in the vertical direction. It is very common that dpiX and dpiY will be the same:

float dpiX, dpiY;
Graphics graphics = this.CreateGraphics();
dpiX = graphics.DpiX;
dpiY = graphics.DpiY;

Note: Most programs are poorly written, and do not handle high-dpi display settings properly. Because of this, starting with Windows Vista, Microsoft lies to any application that does not specifically declare that it correctly supports high-dpi displays. Applications are told that the display is still set to the (legacy default) 96dpi. Windows then uses the video card to resize your application to make it larger:

enter image description here

You opt out of high-dpi scaling by adding an entry to your application's manifest:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
    <assemblyIdentity 
            version="1.0.0.0"
            processorArchitecture="X86"
            name="client"
            type="win32"
    /> 

    <description>My Super Cool Application</description> 

    <!-- We are high-dpi aware on Windows Vista -->
    <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
        <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
            <dpiAware>true</dpiAware>
        </asmv3:windowsSettings>
    </asmv3:application>

    <!-- We were designed and tested on Windows 7 -->
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
        <application>
            <!--The ID below indicates application support for Windows Vista -->
            <!--supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/ -->
            <!--The ID below indicates application support for Windows 7 -->
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
        </application>
    </compatibility>

    <!-- Disable file and registry virtualization -->
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
            </requestedPrivileges>
        </security>
    </trustInfo>

</assembly>