System Power Status

The system power status indicates whether the source of power for a computer is a system battery or AC power. For computers that use batteries, the system power status also indicates how much battery life remains and whether the battery is charging.

Power information is retrieved by registering for power setting notifications through the RegisterPowerSettingNotification function. This function allows applications to register for specific power settings and be notified when they change.

Windows Server 2003 and Windows XP:  Power status information is retrieved by using the GetSystemPowerStatus function, which copies information about the power supply and battery status to a SYSTEM_POWER_STATUS structure. This structure indicates whether the system has a battery, and if it does, whether the battery is being used, and what percentage of the charge remains. The system broadcasts the PBT_APMPOWERSTATUSCHANGE event to all applications when the power status changes. When your application receives this event, it should call GetSystemPowerStatus again to determine what changed.

Applications and installable drivers typically use the system power status to determine whether continued operation is feasible. For example, before an application performs background operations such as compressing or paginating a file, it should check whether the system is on batteries. As another example, an application that is beginning a lengthy operation should check the status to determine whether enough battery power exists to complete the operation.

By default, the system does not query applications or drivers during sleep transitions.

Windows Server 2003 and Windows XP:  If power is low, an application can request user intervention or request that the system shut itself down. You can suspend system operation by using the SetSystemPowerState function. This generates a power management event that, if approved by all applications and drivers in the system, shuts down the system until the user restores power.

Applications should also use the GetDevicePowerState function to check whether the hard disk drive is turned off. Applications that do not perform these checks can cause the hard disk drive to turn on frequently, reducing any power saved by the system through power management. Instead, applications should wait until the user performs an action that causes the hard disk drive to turn on before performing background operations. Applications should also shut down when possible, to save power and reduce noise.

Related topics

About Power Management

 

 

Community Additions

ADD
Show:
© 2014 Microsoft