1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Battery Life

Discussion in 'Delphi Programming' started by saedi_mehdi, Dec 2, 2013.

  1. saedi_mehdi
    Offline

    saedi_mehdi DF Junior

    battery life in delphi code

    function GetBatteryLifePercent: Byte;
    var
      Sps: TSystemPowerStatus;
    begin
      GetSystemPowerStatus(Sps);
      result:= Sps.BatteryLifePercent;
    end;
     
  2. saedi_mehdi
    Offline

    saedi_mehdi DF Junior

    in this one tou can get time of life.

    function GetBatteryLifeTime: Integer;
    var
      Sps: TSystemPowerStatus;
    begin
      GetSystemPowerStatus(Sps);
      result:= Sps.BatteryLifeTime;
    end;
     
  3. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    do you need component for this code ?
     
  4. saedi_mehdi
    Offline

    saedi_mehdi DF Junior

  5. saedi_mehdi
    Offline

    saedi_mehdi DF Junior

    you must use windows unit
     
  6. saedi_mehdi
    Offline

    saedi_mehdi DF Junior

    function GetBatteryState: TDWBatteryStates;
    var
      Sps: TSystemPowerStatus;
    begin
      GetSystemPowerStatus(Sps);
      with Sps do begin
          if ((BatteryFlag and 1) = 1) then Include(result, dwbtsHigh);
          if ((BatteryFlag and 2) = 2) then Include(result, dwbtsLow);
          if ((BatteryFlag and 4) = 4) then Include(result, dwbtsCritical);
          if ((BatteryFlag and 8) = 8) then Include(result, dwbtsCharging);
          if ((BatteryFlag and 128) = 128) then Include(result, dwbtsNoSystemBattery);
          if ((BatteryFlag and 255) = 255) then Include(result, dwbtsUnknownState);
      end;
    end;
     
  7. amir_kh1845
    Offline

    amir_kh1845 DF Member

    perfect
    thank saedi
    itested it
    very very good
     
  8. saedi_mehdi
    Offline

    saedi_mehdi DF Junior

  9. emarti
    Offline

    emarti DF Junior

    nice code!
     

Share This Page