我需要获得显示器支持的最大屏幕分辨率,而不是当前容易的分辨率。任何帮助将不胜感激。
编辑:这是适用于我的更新解决方案。
public Size GetMaximumScreenSizePrimary()
{
var scope = new System.Management.ManagementScope();
var q = new System.Management.ObjectQuery("SELECT * FROM CIM_VideoControllerResolution");
using (var searcher = new System.Management.ManagementObjectSearcher(scope, q))
{
var results = searcher.Get();
UInt32 maxHResolution = 0;
UInt32 maxVResolution = 0;
foreach (var item in results)
{
if ((UInt32)item["HorizontalResolution"] > maxHResolution)
maxHResolution = (UInt32)item["HorizontalResolution"];
if ((UInt32)item["VerticalResolution"] > maxVResolution)
maxVResolution = (UInt32)item["VerticalResolution"];
}
log.Debug("Max Supported Resolution " + maxHResolution + "x" + maxVResolution);
}
return new Size(maxHResolution, maxVResolution);
}
答案 0 :(得分:3)
从管理范围中获取结果。
var scope = new System.Management.ManagementScope();
var q = new System.Management.ObjectQuery("SELECT * FROM CIM_VideoControllerResolution");
using (var searcher = new System.Management.ManagementObjectSearcher(scope, q))
{
var results = searcher.Get();
foreach (var item in results)
{
Console.WriteLine(item["Caption"]);
}
}
有关可用信息的详细信息,请参阅CIM_VideoControllerResolution页面。
答案 1 :(得分:1)
获取newWidth& newHeight of screen resolution如下所示,并在需要的地方使用它们
Screen scr = Screen.PrimaryScreen;
int newWidth = scr.Bounds.Width;
int newHeight = scr.Bounds.Height;
答案 2 :(得分:-1)