There is setting for Display in Windows 7 (Control Panel -> Display). It allows to change the size of the text and other items on the screen. I need to get this setting to be able to switch on/switch off some functionality in my C# application based on the setting value. Is that possible?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Here's a solution that works nicely in Windows 10. There's no need for DPI awareness or anything.
This is a very old question, but since Windows 8.1, one can use various other functions, like
GetDpiForWindow
In C#:
For this to work correctly on Windows 10 anniversary, you need to add an
app.manifest
to your C# project:I think this should provide you with the information you are looking for:
http://www.pinvoke.net/default.aspx/user32.getsystemmetrics
http://pinvoke.net/default.aspx/Enums.SystemMetric
Edit - oh sorry it looks like there is an easier way to get this information now without a pinvoke,
http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.aspx
This setting is the screen DPI, or dots per inch.
Read it like so:
I don't think it's possible at the moment for the X and Y values to be different. A value of 96 corresponds to 100% font scaling (smaller), 120 corresponds to 125% scaling (medium) and 144 corresponds to 150% scaling (larger). However, users are able to set values other than these standard ones.
Do be aware that unless your application is declared to be DPI aware, then the values you observe may be subject to DPI virtualization.