访问用户的可能屏幕分辨率 - C#2010 [英] Access User's Possible Screen Resolutions - C# 2010
问题描述
感谢您的帮助。
我想知道如何访问用户PC上的屏幕分辨率。
I am wondering how I might go about accessing the screen resolutions available on a user's PC. I would like to get a list of all available resolutions and also determine what the user is current running at.
推荐答案
我相信你可以在User32.dll中进行 PInvoke 调用 EnumDisplaySettings api调用。
I believe you can make a PInvoke call to EnumDisplaySettings api call in User32.dll.
[DllImport("user32.dll")]
public static extern bool EnumDisplaySettings (string deviceName, int modeNum, ref DEVMODE devMode );
查看示例此处。
您将会遇到双显示器系统的复杂问题,
You'll of course run into complications with dual-monitor systems, but to get the current screen you can do
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
我假设你正在谈论一个可执行文件而不是一个ASP.Net应用程序,但如果你需要在Javascript中的屏幕大小,你可以使用屏幕对象。
I assumed you were talking about an executable and not an ASP.Net app, but if you need the screen size in Javascript, you can use the screen object.
screen.width; screen.height; screen.colorDepth;
这篇关于访问用户的可能屏幕分辨率 - C#2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!