function GetIfTable(pIfTable: PMIB_IFTABLE;var pdwSize: ULONG; bOrder: BOOL): DWORD; stdcall;external iphlpapilib name'GetIfTable'; function SetIfEntry(const pIfRow: MIB_IFROW): DWORD; stdcall;external iphlpapilib name'SetIfEntry';
procedure TFrmMain.Button1Click(Sender: TObject); var
dwSize: DWORD;
mit: PMIB_IFTABLE;
i:integer; begin //dwSize := 0; //mit :=nil;
GetIfTable(nil, dwSize, TRUE);
mit := GetMemory(dwSize); if GetIfTable(mit, dwSize, TRUE)= NO_ERROR then for i := 0 to Pred(mit^.dwNumEntries)do begin
mit^.table[i].dwAdminStatus := MIB_IF_ADMIN_STATUS_DOWN; if SetIfEntry(mit^.table[i])= NO_ERROR then
Showmessage('Stop Adapter(' + IntToStr(mit^.table[i].dwIndex) + ')'
+ pchar(@mit^.table[i].bDescr[0]) + ' succeed.'); end;
FreeMemory(mit); end;
procedure TFrmMain.Button2Click(Sender: TObject); var
dwSize: DWORD;
mit: PMIB_IFTABLE;
i:integer; begin //dwSize := 0; //mit :=nil;
GetIfTable(nil, dwSize, TRUE);
mit := GetMemory(dwSize); if GetIfTable(mit, dwSize, TRUE)= NO_ERROR then for i := 0 to Pred(mit^.dwNumEntries)do begin
mit^.table[i].dwAdminStatus := MIB_IF_ADMIN_STATUS_UP; if SetIfEntry(mit^.table[i])= NO_ERROR then
Showmessage('Start Adapter(' + IntToStr(mit^.table[i].dwIndex) + ')'
+ pchar(@mit^.table[i].bDescr[0]) + ' succeed.'); end;
FreeMemory(mit); end;