uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Windows, contnrs, utilwmi, ComObj, Variants, ActiveX;
....
procedure TForm1.Start1Click(Sender: TObject);
var
tmpint1 : int64; //not currently used. Reserved for catching multiple batteries
f, j : integer;
retVal : string;
WMIResult : TFPObjectList;
begin
ausgabe1.Clear; //TMemo
// This responds with OK
WMIResult := GetWMIInfo('Win32_Battery', ['Status']);
if (WMIResult.Count > 0) then
begin j := 0;
retVal := TStringList(WMIResult[f]).ValueFromIndex[j];
ausgabe1.append(j.ToString + ' C Battery : ' + retVal);
end;
// This responds with <Null>
WMIResult := GetWMIInfo('Win32_Battery', ['DesignCapacity']);
if (WMIResult.Count > 0) then
begin j := 0;
retVal := TStringList(WMIResult[f]).ValueFromIndex[j];
ausgabe1.append(j.ToString + ' C DC : ' + retVal);
end;
// This responds with <Null>
WMIResult := GetWMIInfo('Win32_Battery', ['FullChargeCapacity']);
if (WMIResult.Count > 0) then
begin j := 0;
retVal := TStringList(WMIResult[f]).ValueFromIndex[j];
ausgabe1.append(j.ToString + ' C FCC : ' + retVal);
end;
// This responds with <Null>
WMIResult := GetWMIInfo('CIM_Battery', ['TimeOnBattery']);
if (WMIResult.Count > 0) then
begin j := 0;
retVal := TStringList(WMIResult[f]).ValueFromIndex[j];
ausgabe1.append(j.ToString + ' C TOB : ' + retVal);
end;
// This responds with <Null>
WMIResult := GetWMIInfo('CIM_Battery', ['EstimatedChargeRemaining']);
if (WMIResult.Count > 0) then
begin j := 0;
retVal := TStringList(WMIResult[f]).ValueFromIndex[j];
ausgabe1.append(j.ToString + ' C ECR : ' + retVal);
end;
WMIResult.Free;
//readln;
end;