Time to provide a little balance to the previous piece on SetPowerRequirement for Smartphone which looked at the scenario of ensuring the backlight remained on. You might also want to manually turn off the backlight (or another peripherial) to save power. You can do this with SetDevicePower. You pass in the identifier of the hardware device ("BKL1:" being the backlight on most devices), and a power state - thus the backlight can be powered off with the following:-
SetDevicePower("BKL1:", POWER_NAME, DevicePowerState.D4);
POWER_NAME is passed in to the flags argument to indicate that the first argument represents a device name. The Power states run from D0 full power to D4 power off. And without further ado, the P/Invoke:-
public enum DevicePowerState : int{Unspecified = -1,D0 = 0, // Full On: full power, full functionalityD1, // Low Power On: fully functional at low power/performanceD2, // Standby: partially powered with automatic wakeD3, // Sleep: partially powered with device initiated wakeD4, // Off: unpowered}private const int POWER_NAME = 0x00000001;[DllImport("coredll")]private static extern int SetDevicePower(string pvDevice, int dwDeviceFlags,DevicePowerState DeviceState);
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.