Power onoff PDA screen

On December 24, 2008, in Programming, by Mike Hudson

If you want to conserve battery power, but dont want to switch off or suspend your device you can use this code to simply switch off the display!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Namespace PDA
Public Class Video
Private Const SETPOWERMANAGEMENT As Int32 = 6147
Declare Function ExtEscapeSet Lib "coredll" Alias "ExtEscape" (ByVal hdc As IntPtr, _
ByVal nEscape As Int32, _
ByVal cbInput As Int32, _
ByVal plszInData As Byte(), _
ByVal cbOutput As Int32, _
ByVal lpszOutData As IntPtr) As Int32
Declare Function GetDC Lib "coredll" (ByVal hwnd As IntPtr) As IntPtr
Public Enum VideoPowerState As Integer
VideoPowerOn = 1
VideoPowerStandBy
VideoPowerSuspend
VideoPowerOff
End Enum
Public Shared Sub PowerOff()
Dim hdc As IntPtr = GetDC(IntPtr.Zero)
Dim vpm() As Byte = {12, 0, 0, 0, 1, 0, 0, 0, VideoPowerState.VideoPowerOff, 0, 0, 0, 0}
ExtEscapeSet(hdc, SETPOWERMANAGEMENT, 12, vpm, 0, IntPtr.Zero)
End Sub
Public Shared Sub PowerOn()
Dim hdc As IntPtr = GetDC(IntPtr.Zero)
Dim vpm() As Byte = {12, 0, 0, 0, 1, 0, 0, 0, VideoPowerState.VideoPowerOn, 0, 0, 0, 0}
ExtEscapeSet(hdc, SETPOWERMANAGEMENT, 12, vpm, 0, IntPtr.Zero)
End Sub
End Class
End Namespace
Tagged with:  

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!