我需要获得显示器支持的最大屏幕分辨率,而不是当前分辨率,这很容易。任何帮助将不胜感激。
编辑:这是对我有用的更新解决方案。
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);
}
最佳答案
从管理范围获取结果。
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页面。
关于c# - 如何使用C#获取显示器支持的最大屏幕分辨率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7537078/