更改Windows dpi设置C# [英] Change windows dpi setting C#
问题描述
我遇到与Windows的dpi设置有关的问题。如果将Windows dpi设置设为100%,则一切正常。但是,如果用户将其更改为125%...我的应用程序的某些部分显示了错误的大小。我知道问题并且知道如何处理,但是我的客户希望在应用程序运行时,如果Windows的当前dpi设置不等于100%->将其更改为100%
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%
我仍然坚持解决方案。您是否有解决方案来更改Windows dpi设置值?
And I'm standing still with the solution. Do you have some solution to change windows dpi setting value?
感谢进阶!!!
推荐答案
您可以通过修改注册表项 HKEY_CURRENT_USER\控制面板\桌面:LogPixels
的注册表值来实现。类型为 REG_DWORD
。
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.
将值设置为96(0x60)对应于将DPI设置设置为较小(100%)。
Setting the value to 96 (0x60) corresponds setting the DPI settings to "Smaller" (100%).
- 96是小(100%),
- 120是中(125%),
- 144是大 (150%)。
请注意,计算机可能仍需要重新启动或注销/登录才能使一切正常运行设置。
Note that the computer may still require a reboot or logout/login to make everything work as expected with that setting.
这篇关于更改Windows dpi设置C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!