Click here to Skip to main content
13,146,402 members (45,425 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 21 Mar 2005

Using .NET CF P/Invoke to Turn off PDA Screen

, 21 Mar 2005
Rate this:
Please Sign up or sign in to vote.
An article on how to turn off PDA screen on the .NET CF platform.

Sample Image


It's sometimes useful to turn off the PDA screen to save power while your application is running in the background, e.g., if you design a music player, the user may want to turn off the screen for longer play time.

Unfortunately, there are few articles on this topic. One C++ program I have found is on MSDN. And thank one's lucky stars, I also found another C# program from OpenNET CF. Then I rewrote it and tested for VB.NET.

Using the code

It's easy to use this code, you simply call Video.PowerOff under the PDA namespace. When your screen is turned off, you can turn it on using Video.PowerOn Sub, or you can press the Power button on your PDA.

The core function here is ExtEscape in "Coredll.dll". This function allows applications to access the capabilities of a particular device that are not available through the graphics display interface (GDI). The device capabilities this function accesses must be implemented by an OEM.

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

A return value greater than zero indicates success and less than zero indicates an error. You can get detail information from the MSDN Library.

To use this function, first you must have a hdc returned by GetDC function. Then the nEscape parameter is set to SETPOWERMANAGEMENT where the value is 0x1803. The cbInput parameter is the length of plszInData. Here the plszInData is some structure. I define it like this:

Dim vpm() As Byte = {12, 0, 0, 0, 1, 0, 0, 0, _
                     VideoPowerState.VideoPowerOff, 0, 0, 0, 0}

Here the 9th value is from VideoPowerState enumeration:

Public Enum VideoPowerState As Integer
    VideoPowerOn = 1
End Enum

And the last parameter cbOutput and lpszOutData should be set to zero. In the end, call ExtEscapeSet function to turn off/on your screen.

Although the function works well, I was confused by the structure of plszInData and what extra usage of ExtEscape function. Can anyone tell me about it? Thanks!

Points of Interest

Contact me

Thanks for reading and using my code.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
China China
I'm a undergraduate student in UESTC in China.
I have being learing computer for more than ten years. And now studying programming and have some software made by myself.
I learned SMS technology and did some work on OBEX, PDU, AT commands, IrDA and so on.
If you have interested in this field, please contact me.
And see more on my web site:

You may also be interested in...


Comments and Discussions

GeneralHi Pin
Solanki Rajat14-May-08 0:16
memberSolanki Rajat14-May-08 0:16 
QuestionHow To Check Current Status? Pin
Reza Ghorbani19-Aug-07 20:01
memberReza Ghorbani19-Aug-07 20:01 
GeneralHandy for .NET Show Pin
frenchroast29-Mar-05 13:33
memberfrenchroast29-Mar-05 13:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170915.1 | Last Updated 21 Mar 2005
Article Copyright 2005 by hesicong
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid