How does GetMonitorBrightness http://msdn.microsoft.com/en-us/library/ms775205.aspx work? Can someone give me an actual working implementation calling this code in C#?
I'm trying to retrieve the allowed brightness levels my laptop supports.
I have the following working code that sets the brightness from 1 to ~150. But I'm looking for the allowed input values (min max values).
static void SetBrightness(byte targetBrightness)
{
ManagementScope scope = new ManagementScope("root\\WMI");
SelectQuery query = new SelectQuery("WmiMonitorBrightnessMethods");
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query))
{
using (ManagementObjectCollection objectCollection = searcher.Get())
{
foreach (ManagementObject mObj in objectCollection)
{
mObj.InvokeMethod("WmiSetBrightness",
new Object[] { UInt32.MaxValue, targetBrightness });
break;
}
}
}
}
While using Interop should be possible this function is also available through WMI. Changing my original code a bit resulted in the following code that should work:
Now I'm really curious how to handle 'special' cases like non laptop Screen's and if they implement any way to influence brightness.
The function has an output of the minimum and maximum values:
This is assuming that you want the values for the first monitor.