Created
April 6, 2014 08:37
-
-
Save aNNiMON/10003154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static ushort GetMonitorBrightness() { | |
using (var mclass = new ManagementClass("WmiMonitorBrightness")) { | |
mclass.Scope = new ManagementScope(@"\\.\root\wmi"); | |
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(@"\\.\root\wmi"); | |
using (var instances = mclass.GetInstances()) { | |
foreach (ManagementObject instance in instances) { | |
object[] args = new object[] { 1, brightness }; | |
instance.InvokeMethod("WmiSetBrightness", args); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment