Intermec 6200 Reference Guide

Page of 410
SECTION 3
Supporting Windows Applications
3-18    PEN*KEY
R
 6200/6300 Hand-Held Computer Programmer’s Reference Guide
GetPowerStatus
Fills a 
tagPOWER_STATUS
 structure with current power status values.
Determines whether ac is on line to detect docking and to check battery status.
tagPOWER_STATUS
This structure transfers power information.  The structure is six bytes long,
although, as documented earlier, some APM event broadcasts return the first or
last four bytes of the structure in the 32Ćbit optional parameter.
GetPowerState
Returns APM state for particular APM or OEMĆdefined devices.
SetPowerState
Sets APM power state of a particular APM or OEMĆdefined device.  If the
SYSTEM device is set to 
SUSPEND
, SetPowerState treats the request the same
as a suspend timeout and broadcasts the suspend request to the system, then
suspend the system.  If an application or driver fails the suspend request,
SetPowerState returns 
PWR_FAIL
.
SystemActivity
Call this function to indicate that system or user activity has occurred.  This
keeps the system from timing out into standby (backlight off) or suspend.  This
function is typically called by drivers that control communications (serial,
Ethernet) or user input (scanner) peripherals.  Applications can also call this
function to indicate that they are busy during long periods of processing;
however, it is preferable that applications receive and process the
SUSPENDREQUEST message.
Power Management by Windows Applications
A Windows application can benefit system power management by allowing the
CPU to idle, by closing unused devices, and by suspending the system when the
application knows that the user is idle.
Saving CPU Power
To maintain good system response in a multiĆtasking system like Windows, you
should minimize the use of busy loops.  Busy loops, moreover, waste system
power.  Applications should be careful to never busyĆwait when implementing
timeouts or polling routines.  Instead, a system timer should be used, thereby
allowing the system to continue to idle during periods of inactivity.
Another practice to avoid is the use of 
PeekMessage
 loops instead of 
GetMessage
loops.  Calling 
PeekMessage
 to see whether a message is waiting for you does
allow other Windows applications to run if they have messages, which keeps
your application friendly.  But if there are no messages pending, 
PeekMessage
3. Windows
Applications