Asked By Wolfgang Hauer
28-Mar-07 12:57 PM

Hi all!
My device is a HTC P3300 (Phone + GPS) PDA.
I have from http://www.peterfoot.net/KeepYourSmartphoneBacklightOn.aspx
grabbed a class wich should be able to turn the backlight ON/OFF. But it
does'nt work. I got a handle from
SetPowerRequirement(). But no change. Any ideas?
Thanks
Wolfgang
Public Class Backlight
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
'ensure the power requirement is released
Protected Overrides Sub Finalize()
Release()
End Sub
'handle to the power requirement
Private handle As IntPtr
Private Enum PowerState
PwrDeviceUnspecified = -1
D0 = 0 'full on _
D1 = 1 'low power
D2 = 2 'standby
D3 = 3 'sleep
D4 = 4 'off
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
'keep the backlight lit
Public Sub DeActivate()
'request no power
handle = SetPowerRequirement("BKL1:", PowerState.D4, 1, IntPtr.Zero, 0)
End Sub
Public Function PowerSettingChanged() As Boolean
If handle = IntPtr.Zero Then
Return False
Else
Return True
End If
End Function
'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
End Class