Probier mal das...
Delphi-Quellcode:
procedure TForm1.Timer1Timer(Sender: TObject);
var
wmi : OleVariant;
// <----
wmiService : variant;
nicstatus : Olevariant;
// <----
card : Olevariant;
cnt : integer;
Enum: IEnumVariant;
P : IUnknown;
F : Cardinal;
connected : integer;
status :
string;
begin
ListBox1.clear;
WMI:=CreateOleObject('
WbemScripting.SWbemLocator');
try // <----
wmiService :=
wmi.ConnectServer('
.', '
root\wmi');
nicstatus := wmiService.InstancesOf('
MSNdis_MediaConnectStatus');
try // <----
p := nicstatus._NewEnum;
p.QueryInterface(IEnumVariant, Enum);
for cnt := 0
to nicstatus.Count - 1
do
begin
Enum.Next(1, card, F);
try
connected := card.NdisMediaConnectStatus;
if (connected = 0)
then
begin
Status := '
verbunden';
end
else
begin
Status := '
nicht verbunden';
end;
ListBox1.Items.Add( card.InstanceName + '
: ' + status);
finally
card := unassigned;
end;
end;
finally // <----
nicstatus := unassigned;
// <----
end;
// <----
finally // <----
wmi := unassigned;
// <----
end;
// <----
end;
Edit: Hab es gerade mal ausprobiert, bei mir bleibt der Arbeitsspeicher stabil.