如何找到活动的(使用中的)图形卡? C#
How to find Active (In Use) Graphic Cards? C#
我使用此代码查找显卡:
ManagementScope scope = new ManagementScope("\\.\ROOT\cimv2");
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_VideoController");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
string graphicsCard = "";
foreach (ManagementObject mo in queryCollection)
{
foreach (PropertyData property in mo.Properties)
{
if (property.Name == "Description")
{
graphicsCard += property.Value.ToString() + " ";
}
}
}
我有两张显卡:
以上代码return所有显卡。
如何找到windows选择的活动显卡?
试试这个
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
string graphicsCard = string.Empty;
foreach (ManagementObject obj in searcher.Get())
{
if (obj["CurrentBitsPerPixel"] != null && obj["CurrentHorizontalResolution"] != null)
{
graphicsCard = obj["Name"].ToString();
}
}
我使用此代码查找显卡:
ManagementScope scope = new ManagementScope("\\.\ROOT\cimv2");
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_VideoController");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
string graphicsCard = "";
foreach (ManagementObject mo in queryCollection)
{
foreach (PropertyData property in mo.Properties)
{
if (property.Name == "Description")
{
graphicsCard += property.Value.ToString() + " ";
}
}
}
我有两张显卡:
以上代码return所有显卡。
如何找到windows选择的活动显卡?
试试这个
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
string graphicsCard = string.Empty;
foreach (ManagementObject obj in searcher.Get())
{
if (obj["CurrentBitsPerPixel"] != null && obj["CurrentHorizontalResolution"] != null)
{
graphicsCard = obj["Name"].ToString();
}
}