library WMICall_DLL;
uses
Sharemem, SysUtils,
Classes,
WMIfunctions
in '
WMIfunctions.pas';
type
Twmistring =
array [0..30]
of array [0..7]
of String;
{$R *.res}
function getwmiinfo(comp, namespace, username, pass,
query:
String; vista: Boolean):Twmistring;
Var WMIResults: TWMIInfo;
i, i2: Integer;
wmidrives:Twmistring;
begin
{
Instance
Caption
DeviceID
Partitions
SerialNumber
Signature
Size
}
if not WMIGetInfo(comp, namespace, username, pass, Trim(
query), WMIResults)
then
begin
wmidrives[0,0] := '
ERROR';
Exit;
end;
wmidrives[0,0] := '
';
if WMIResults.Instance =
nil then
begin
Exit;
end;
//WMIResults.Instance: Anzahl der Instanzen (Laufwerke) (Spalten)
//WMIResults.PropName: Anzahl der Querys (in dem Fall 6) (Zeilen)
For i := 0
to Length(WMIResults.Instance)
do
If i = 0
Then
wmidrives[i, 0] := '
Instance'
Else
wmidrives[i, 0] := IntToStr(i);
if vista
then
begin
For i2 := 0
to High(WMIResults.PropName)
do
Begin
wmidrives[0, i2 + 1] := WMIResults.PropName[i2];
//6
For i := 0
to High(WMIResults.Instance)
do
begin
wmidrives[i + 1, i2 + 1] := WMIRead(WMIResults, i, i2);
end;
End;
end
else
begin
For i2 := 0
to High(WMIResults.PropName)
do
Begin
if i2 >= 3
then
begin
wmidrives[0, i2 + 2] := WMIResults.PropName[i2];
For i := 0
to High(WMIResults.Instance)
do
wmidrives[i + 1, i2 + 2] := WMIRead(WMIResults, i, i2);
end
else
begin
wmidrives[0, i2 + 1] := WMIResults.PropName[i2];
For i := 0
to High(WMIResults.Instance)
do
wmidrives[i + 1, i2 + 1] := WMIRead(WMIResults, i, i2);
end;
End;
end;
for i := 1
to Length(WMIResults.Instance)
do
begin
if wmidrives[i, 6] = '
NULL'
then //Size
wmidrives[i, 6]:='
0';
if wmidrives[i, 3] = '
NULL'
then //Partitions
wmidrives[i, 3]:='
0';
if length(wmidrives[i, 5])<=1
then //Sig
wmidrives[i, 5]:='
-';
if length(wmidrives[i, 4])<=1
then//Serial
wmidrives[i, 4]:='
-';
end;
end;
exports
getwmiinfo;
begin
end.