如何控制PDA背景燈光

摘要:如何控制PDA背景登光

程式啟動時,user希望不要進入省電模式

希望螢幕的背光一直處於開啟的狀態 


 
  Private Declare Function SetPowerRequirement Lib "coredll.dll" () 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 
 
'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() Sub Activate() 
 
    'request full power 
 
    handle = SetPowerRequirement("BKL1:", PowerState.D0, 1, IntPtr.Zero, 0) 
 
  End Sub 
 
  'keep the backlight lit 
 
  Public Sub DeActivate() Sub DeActivate() 
 
    'request no power 
 
    handle = SetPowerRequirement("BKL1:", PowerState.D4, 1, IntPtr.Zero, 0) 
 
  End Sub 
 
End Class 

有用到的只有:

Activate() 背光開啟
DeActivate() 背光關閉
其中的PowerState 模式有四種,說明如下

 

D0
Device is fully powered
D1
Device is functional but in power savings mode
D2
Device is in standby
D3
Device is in sleep mode
D4
Device is Unpowered

參考來源

 
 
其中最重要的就是coredll.dll這個檔案
在Windows Mobile或CE下,coredll.dll的作用相當於Win32的kernel32.dll
許多對PDA做的動作都必需透過它,如開啟螢幕小鍵盤、震動、撥放音效、電源控制等……

分享