Keep your Smartphone backlight on

If your application involves displaying screen content you probably have come across the issue where the screen backlight turns off after a few seconds of no keypresses. You can override this behaviour in your application using a couple of underdocumented API Power-Management functions. Here is a VB.NET snippet for .NETCF to keep the backlight on:-

Namespace OpenNETCF.WindowsCE.Forms


Public Class Backlight


‘ensure the power requirement is released

Protected Overrides Sub Finalize()


End Sub

‘handle to the power requirement

Private handle As IntPtr


Private Enum PowerState

PwrDeviceUnspecified = -1

‘full on

D0 = 0

‘low power

D1 = 1


D2 = 2


D3 = 3


D4 = 4

PwrDeviceMaximum = 5

End Enum


‘keep the backlight lit

Public Sub Activate()

‘request full power

handle = SetPowerRequirement(“BKL1:”, PowerState.D0, 1, IntPtr.Zero, 0)

End Sub


‘release power requirement

Public Sub Release()

If handle.ToInt32() <> 0 Then

Dim result As Integer

result = ReleasePowerRequirement(handle)

handle = IntPtr.Zero

End If

End Sub

Private Declare Function SetPowerRequirement Lib “coredll.dll” (ByVal pvDevice As String, ByVal DeviceState As PowerState, ByVal DeviceFlags As Integer, ByVal pvSystemState As IntPtr, ByVal StateFlags As Integer) As IntPtr

Private Declare Function ReleasePowerRequirement Lib “coredll.dll” (ByVal handle As IntPtr) As Integer

End Class

End Namespace

Thanks to Paul O’Brien from MoDaCo for inspiring and helping test the code.