News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

QA: How to suspend Pocket PC device?

By Andrey Yatsyk, October 08, 2001.
Print version

Question

How to suspend Pocket PC device from my embedded Visual C++ program? I need the same effect as pressing "Power Off" button.

Answer

There are two ways of device suspension on Pocket PC. The first one is to emulate pressing on power off button. On Pocket PC this button has a key code as any other one. The device will be suspended after execution of following code:

::keybd_event(VK_OFF, 0, 0, 0); ::keybd_event(VK_OFF, 0, KEYEVENTF_KEYUP, 0);

When the application has been turned on the execution of your program continues from line follows keybd_event code.

The other way of application suspension is to use undocumented PowerOffSystem() function. As this function is undocumented I can't make any assumptions abut support of this function in different devices or operating system versions. In order to use this function place following function declaration into your source code:

extern "C" __declspec(dllimport) void PowerOffSystem();

You can simply invoke PoverOffSystem() from your code after that.

Related resources:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House