5,392
社区成员
发帖
与我相关
我的任务
分享
labMAC.Caption := Obj.Properties_.Item('MACAddress',0).Value;
Obj := Obj.Properties_.Item('IPAddress',0).Value;
Obj := Obj[0];
labIP.Caption := Obj;
var
WMi, Objs, Obj, Value: OleVariant;
Enum: IEnumVariant;
C: Cardinal;
s: array of string;
i: Integer;
Name, IP: string;
begin
IP := '';
Wmi:= CreateOleObject('WbemScripting.SWbemLocator');
Objs := Wmi.ConnectServer('.','root\cimv2')
.ExecQuery('Select * from Win32_NetworkAdapterConfiguration where IPEnabled!=0');
Enum := IEnumVariant(IUnknown(Objs._NewEnum));
Enum.Reset;
C := 0;
while Succeeded(Enum.Next(1, Obj, C)) and (C > 0) do
begin
begin
Name := Obj.Properties_.Item('Description', 0).Value;
s := Obj.Properties_.Item('IPAddress', 0).Value;
IP := IP + Name + #13#10;
for i := 0 to High(s) do IP := IP + (s[i]) + #13#10;
IP := IP + #13#10;
end;
end;
ShowMessage(IP);
end;