Search code examples
c#.nethighdpi

How to set “Override high DPI scaling” to “Application” programmatically through code


We have a control inside a activex control that suffers from graphical artifacts on Windows 10. It works fine in Windows 7. The only way we have been able to fix the artifacts is by changing the exe setting pictured below.

High DPI scaling override

Is there a way to change it through code (Visual Studio 2017 c#)? In our project we dont have a manifest file in project.


Solution

  • I was able to save the following into a .bat file in order to set DPI scaling.

    This command sets HIGHDPI scaling:

    REG ADD "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /V "C:\Program Files (x86)\VidSys\VidSys Out-of-Process Viewer Framework\External Process\NvrViewerExternalProcess.exe" /T REG_SZ /D ~HIGHDPIAWARE /F
    

    Obviously, you need to replace the path in the command with the absolute path to your EXE.

    To set other types of scaling, use the EXE's property page to set the type of scaling that you want, then check the Windows registry for the key named in the above command. Then adjust the command by substituting in the string you find in the registry.