Получение / установка яркости монитора через управляемый вызов WMI
public static ushort GetMonitorBrightness() {
using (var mclass = new ManagementClass("WmiMonitorBrightness")) {
mclass.Scope = new ManagementScope(@"\.rootwmi");
using (var instances = mclass.GetInstances()) {
foreach (ManagementObject instance in instances) {
return (byte) instance.GetPropertyValue("CurrentBrightness");
}
}
}
return 0;
}
public static void SetMonitorBrightness(ushort brightness) {
using (var mclass = new ManagementClass("WmiMonitorBrightnessMethods")) {
mclass.Scope = new ManagementScope(@"\.rootwmi");
using (var instances = mclass.GetInstances()) {
foreach (ManagementObject instance in instances) {
object[] args = new object[] { 1, brightness };
instance.InvokeMethod("WmiSetBrightness", args);
}
}
}
}