是否可以使用C#在Windows 8.1项目或通用Windows应用程序中获取设备(显示器/平板电脑/手机)的当前亮度级别?
我从System.Management dll获得了一个查询代码。
static int GetBrightness()
{
System.Management.ManagementScope s = new System.Management.ManagementScope("root\\WMI");
System.Management.SelectQuery q = new System.Management.SelectQuery("WmiMonitorBrightness");
System.Management.ManagementObjectSearcher mos = new System.Management.ManagementObjectSearcher(s, q);
System.Management.ManagementObjectCollection moc = mos.Get();
byte curBrightness = 0;
foreach (System.Management.ManagementObject o in moc)
{
curBrightness = (byte)o.GetPropertyValue("CurrentBrightness");
break;
}
moc.Dispose();
mos.Dispose();
return (int)curBrightness;
}
但那不适用于应用项目。