Created
          May 30, 2014 09:37 
        
      - 
      
- 
        Save 2no/9d5918439945edb67dfd to your computer and use it in GitHub Desktop. 
    Cygwin, gcc-g++ $ make battery
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include <iostream> | |
| #include <windows.h> | |
| int main(int argc, char *argv[]) | |
| { | |
| SYSTEM_POWER_STATUS powerStatus; | |
| int percent = 0; | |
| if (GetSystemPowerStatus(&powerStatus) == TRUE) { | |
| percent = (int)powerStatus.BatteryLifePercent; | |
| } | |
| std::cout << percent << std::endl; | |
| return 0; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment