Click here to Skip to main content
13,410,132 members (37,176 online)
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 31 Mar 2005

Suspend Killer for WinCE.NET 4.2

Rate this:
Please Sign up or sign in to vote.
WinCE system suspend


Have you tried to keep the device which is running on WinCE.NET without going to suspend while watching video. Here's how to do it without changing the power settings manually.


I was developing a video play back module for WinCE.NET 4.2 and encountered a problem that the system goes to suspend mode according to the settings in the registry while watching a video. First, the backlight goes off and afterwards the system goes to suspend mode. The way normally we do is change the settings in power manager which is not practical every time.

Using the code

I tried to stop it calling SystemIdleTimerReset() but it was unable to stop the device going to suspend sometimes. Because, we have to check the timeout when the power manager event gets fired and call the SystemIdleTimerReset() before it. Calling SystemIdleTimerReset() in a thread or timer works. But we need to consider about the performance since it is a mobile device.

So I tried to do it by firing a key board event to the application message loop. Key board events were generated in a timer process and did it as follows:

//Define the constants to generate key board event
#define VK_NONAME       0xFC

//in the timer process added the following line
keybd_event(VK_NONAME, 0, KEYEVENTF_KEYUP, 0);

It worked fine. Device did not go to suspend mode. But application gets an extra message, and since it is a mobile device, I thought it is better to get rid of this extra process and find a nice solution which does not affect the application performance. Finally, I was able to develop a nice and robust class which does the task I want as it is. So I called it SuspendKiller. SuspendKiller uses the registry, power manager notification call and Backlight power request call to accomplish the task.

Suspend Killer functions in the following sequence:

  1. Loads the settings from the registry and saves those in an array for future reference.
  2. Sets the new settings to Never (0) in the relevant registry keys.
  3. Notifies the Power Manager event to re-load the settings from the registry.
  4. Turn On the backlight with full power.
  5. When the function is called with FALSE parameter, it reveres everything. (Sets the original values, releases the backlight power.)

It does not affect the application performance since we do it once when the media is about to play and stop.

To do this task, I tried many approaches and also tried with interrupts. But I think this solution is nice and clean. Also tested with iMX21 ADS with WinCE.NET 4.2 and worked perfectly while watching a video for more than one hour.


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


About the Author

No Biography provided

You may also be interested in...


Comments and Discussions

GeneralUrgent Pin
Sunshine Always14-Dec-09 4:08
memberSunshine Always14-Dec-09 4:08 
GeneralSuperb Pin
ramesh bs2-Sep-09 4:40
memberramesh bs2-Sep-09 4:40 
QuestionHead file "Pm.h", cannot find it Pin
Anthony S.14-Jul-06 0:13
memberAnthony S.14-Jul-06 0:13 
AnswerRe: Head file "Pm.h", cannot find it Pin
ajith27-Oct-06 0:54
memberajith27-Oct-06 0:54 
QuestionGuarantee registry restore?? Pin
Lewisw16-Jun-06 1:30
memberLewisw16-Jun-06 1:30 
AnswerRe: Guarantee registry restore?? Pin
ajith27-Oct-06 0:42
memberajith27-Oct-06 0:42 
QuestionGot .Net Pin
Jumba666624-Mar-06 5:51
memberJumba666624-Mar-06 5:51 
AnswerRe: Got .Net Pin
ajith18-May-06 22:23
memberajith18-May-06 22:23 
GeneralNot Working in Windows Mobile 5 Pin
miggedy16-Jan-06 9:21
membermiggedy16-Jan-06 9:21 
GeneralRe: Not Working in Windows Mobile 5 Pin
miggedy16-Jan-06 9:50
membermiggedy16-Jan-06 9:50 
GeneralRe: Not Working in Windows Mobile 5 Pin
ajith13-Feb-06 23:35
memberajith13-Feb-06 23:35 
QuestionRe: Not Working in Windows Mobile 5 Pin
roznicki27-Apr-09 11:07
memberroznicki27-Apr-09 11:07 
Generalneed some guidance for power managment in pocket pc Pin
alokb29-Aug-05 7:22
sussalokb29-Aug-05 7:22 
GeneralRe: need some guidance for power managment in pocket pc Pin
ajith13-Feb-06 23:32
memberajith13-Feb-06 23:32 
GeneralRe: need some guidance for power managment in pocket pc Pin
ajith14-Feb-06 0:01
memberajith14-Feb-06 0:01 

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
Web04 | 2.8.180221.1 | Last Updated 1 Apr 2005
Article Copyright 2005 by D. Ajith Nilantha de Silva
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid