Search code examples
c#wpfdpi

Change windows dpi setting C#


I'm facing a issue which related to dpi setting of windows. If the windows dpi setting is set to 100% everything is fine. But if user changed it to 125%...some part of my application displayed a wrong size. I know the problem and I know how to deal with but my customer wants that when application running, if the current dpi setting of windows is not equal to 100% -> change it to 100%

And I'm standing still with the solution. Do you have some solution to change windows dpi setting value?

Thanks in advanced!!!


Solution

  • You can do this by modifying the registry value of the registry key HKEY_CURRENT_USER\Control Panel\Desktop:LogPixels. The type is REG_DWORD.

    You can see the Registry methods here to help how to modify the registry values.

    Setting the value to 96 (0x60) corresponds setting the DPI settings to "Smaller" (100%).

    • 96 is "Smaller" (100%),
    • 120 is "Medium" (125%),
    • 144 is "Larger" (150%).

    Note that the computer may still require a reboot or logout/login to make everything work as expected with that setting.