Changeset 14433 in vbox for trunk/src/VBox/Main/win
- Timestamp:
- Nov 20, 2008 5:50:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/win/HostPowerWin.cpp
r14087 r14433 24 24 *******************************************************************************/ 25 25 #include <windows.h> 26 #include <PowrProf.h> 26 27 27 28 #include <VBox/com/ptr.h> … … 162 163 Log(("PBT_APMPOWERSTATUSCHANGE ACLineStatus=%d BatteryFlag=%d\n", SystemPowerStatus.ACLineStatus, SystemPowerStatus.BatteryFlag)); 163 164 164 /* If the machine has less than 5% battery left (and is not connected to the AC), then we should save the state. */ 165 if ( SystemPowerStatus.ACLineStatus == 0 /* offline */ 166 && SystemPowerStatus.BatteryFlag == 4 /* critical battery status; less than 5% */) 165 if (SystemPowerStatus.ACLineStatus == 0) /* offline */ 167 166 { 168 pPowerObj->notify(HostPowerEvent_BatteryLow); 167 if (SystemPowerStatus.BatteryFlag == 2 /* low > 33% */) 168 { 169 LONG rc; 170 SYSTEM_BATTERY_STATE BatteryState; 171 172 rc = CallNtPowerInformation(SystemBatteryState, NULL, 0, (PVOID)&BatteryState, sizeof(BatteryState)); 173 #ifdef LOG_ENABLED 174 if (rc == 0 /* STATUS_SUCCESS */) 175 Log(("CallNtPowerInformation claims %d seconds of power left\n", BatteryState.EstimatedTime)); 176 #endif 177 if ( rc == 0 /* STATUS_SUCCESS */ 178 && BatteryState.EstimatedTime < 60*5) 179 { 180 pPowerObj->notify(HostPowerEvent_BatteryLow); 181 } 182 } 183 else 184 /* If the machine has less than 5% battery left (and is not connected to the AC), then we should save the state. */ 185 if (SystemPowerStatus.BatteryFlag == 4 /* critical battery status; less than 5% */) 186 { 187 pPowerObj->notify(HostPowerEvent_BatteryLow); 188 } 169 189 } 170 190 }
Note:
See TracChangeset
for help on using the changeset viewer.