使用:ftp://delphi-jedi.org/api/IPHlpAPI.zip
关闭所有网卡:
procedure TForm1.DisplayInterfaceList;
var
IfTable: PMibIfTable;
Row: TMibIfRow;
Size: ULONG;
I, J: Integer;
S,ss: string;
begin
Size := 0;
if not GetIfTable(nil, Size, True) = ERROR_BUFFER_OVERFLOW then Exit;
IfTable := AllocMem(Size);
try
if GetIfTable(IfTable, Size, True) = ERROR_SUCCESS then
begin
for I := 0 to IfTable^.dwNumEntries - 1 do
begin
ss:='';
Row := IfTable^.Table;
ss:=ss+Format('0x%-x ..... ', [Row.dwIndex]);
S := '';
for J := 0 to Row.dwDescrLen - 1 do
S := S + Chr(Row.bDescr[J]);
ss:=ss+s;
Form1.memo1.Lines.Add(ss);
row.dwAdminStatus:=MIB_IF_ADMIN_STATUS_UP;
SetIfEntry(row);
end;
end;
finally
FreeMem(IfTable);
end;
end;