How To Keep a Windows CE Device Alive while Communicating (180898)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • Microsoft Windows CE

This article was previously published under Q180898

SUMMARY

When you are doing serial communications, a device may suspend power based upon a time limit configured by the user. The operating system determines idle time based only upon any type of keyboard entry on the device. This article explains how to keep a Windows CE device alive while you are communicating.

MORE INFORMATION

To determine the time limit that has been configured by the user, you can query the following registry key:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Power\BattPowerOff
					

The BattPowerOff value is a DWORD that represents how long (in seconds) the Handheld PC will wait before suspending itself. There are two methods to prevent this suspension.

Method 1

To avoid device suspension, an application can send a keystroke using keybd_event(). Even sending an UP keystroke, you may still get a keyboard click, so use KEYEVENTF_SILENT to prevent the click from occurring. You should send a key that is currently not being used by the Windows CE operating system so that you can eliminate any potential keyboard conflict. In the following example, an F4 UP keystroke is sent:

keybd_event(VK_F4, 0, KEYEVENTF_KEYUP | KEYEVENTF_SILENT, 0);
					

Method 2

A better solution is to use the API SystemIdleTimerReset() from Coredll.dll. This does not disable the timeout, but resets the idle timer count back to zero. Since the minimum idle timer you can set is one minute, calling this API at intervals of less than one minute will prevent the device from entering suspend mode.

Modification Type:MinorLast Reviewed:7/1/2004
Keywords:kbhowto KB180898