AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Laptop oder Desktop Computer ermitteln??

Ein Thema von Piro · begonnen am 22. Feb 2007 · letzter Beitrag vom 28. Feb 2007
 
Benutzerbild von christian.noeding
christian.noeding

Registriert seit: 26. Mai 2005
Ort: Knw.-Remsfeld
119 Beiträge
 
Delphi XE2 Professional
 
#6

Re: Laptop oder Desktop Computer ermitteln??

  Alt 22. Feb 2007, 18:46
Genügt nicht einfach das Prüfen auf einen Akku? Wäre für mich das Naheliegenste, oder? Jetzt weiß ich nur nicht, inwieweit eine USV als Akku erkannt wird *g*

Da:

Delphi-Quellcode:
function GetPowerStatus(var HasBattery: Boolean; var LoadStatusString: String;
      var LoadstatusPercent: Integer): DWORD;


function TForm1.GetPowerStatus(var HasBattery: Boolean; var LoadStatusString: String;
  var LoadstatusPercent: Integer): DWORD;
var
  SystemPowerStatus: TSystemPowerStatus;
  Text:string;
resourcestring
  rsLoadStatusUnknown = 'Unbekannter Status';
  rsLoadStatusNoBattery = 'Es existiert kein Akku';
  rsLoadStatusHigh = 'Hoher Ladezustand';
  rsLoadStatusLow = 'Niedriger Ladezustand';
  rsLoadStatusCritical = 'Kritischer Ladezustand';
  rsLoadStatusLoading = ' Akku wird geladen';
  rsLoadSatusUnknownLoading = 'Unbekannter Ladezustand';
begin
  SetLastError(0);
  if GetSystemPowerStatus(SystemPowerStatus) then
    with SystemPowerStatus do
    begin
      HasBattery := ACLineStatus = 0;
      // Ladezustand der Batterie
      if (BatteryFlag = 255) then
        LoadStatusString := rsLoadStatusUnknown
      else if (BatteryFlag and 128 = 128) then
        LoadStatusString := rsLoadStatusNoBattery
      else
      begin
        case (BatteryFlag and (1 or 2 or 4)) of
          1: Text := rsLoadStatusHigh;
          2: Text := rsLoadStatusLow;
          4: Text := rsLoadStatusCritical;
        else
          LoadStatusString := rsLoadSatusUnknownLoading
        end;
        if (BatteryFlag and 8 = 8) then
          LoadStatusString := Text + rsLoadStatusLoading
        else
          LoadStatusString:=text+' '+inttostr(LoadstatusPercent)+'% verbleibend';
      end;
      // Ladezustand in Prozent
      if (BatteryLifePercent <> 255) then
        LoadstatusPercent := BatteryLifePercent
      else
        LoadstatusPercent := -1;
  end;
  Result := GetLastError;
end;
Christian Nöding
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:34 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz