Hello,
i have made a function to get System Infos with WMI request (wmi only in Windows) :
Function GetWMIInfo(const WMIClass: string ; const WMIProperty:tstringList;
const Condition: string = ''):tlist;
WMIClass : Class in which to find infos example : Win32_NetworkAdapter
WMIProperty : a list of properties to get example : Name,MACAddress
Condition : a Condition to limit results example : WHERE NETENABLED = TRUE
The result is a list of Properties list.
Usage example to get all the active network cards and their MACAddresses :
procedure TForm1.Button3Click(Sender: TObject);
var ResultatWMI : TList;
Infos : TStringList;
i,j : Integer;
begin
Memo1.Clear;
Infos := TstringList.Create;
// Prepare Infos to get in a Name-Value StringList
Infos.CommaText:='Name=,MACAddress=';
ResultatWMI := GetWMIInfo('Win32_NetworkAdapter',Infos,'WHERE NETENABLED = TRUE');
for i := 0 to ResultatWMI.Count-1 do
begin
Memo1.Lines.add('================================================');
for j := 0 to Infos.Count-1 do
begin
Memo1.Lines.add(TstringList(ResultatWMI[i]).Names[j]+' : '+
TstringList (ResultatWMI[i]).ValueFromIndex[j]);
end;
end;
// Nettoyage - Cleaning
for i := 0 to ResultatWMI.Count-1 do
begin
TstringList(ResultatWMI[i]).Free;
end;
Infos.Free;
end;
Function is in the utilwmi unit ( attachment )
hope help some people with this. If you see errors or optimizations in source code , say it to me.
To be continued if useful.
Friendly, J.P