楼主已有思路了阿,就是先让网卡禁用再启用。 用IphlpApi中的函数 Platform SDK: Internet Protocol Helper SetIfEntryUse the SetIfEntry function to set the administrative status of an interface. DWORD SetIfEntry( PMIB_IFROW pIfRow );Parameters pIfRow [in] Pointer to a MIB_IFROW structure. The dwIndex member of this structure specifies the interface on which to set administrative status. The dwAdminStatus member specifies the new administrative status. The dwAdminStatus member can be one of the following values. Value Meaning MIB_IF_ADMIN_STATUS_UP The interface is administratively enabled. MIB_IF_ADMIN_STATUS_DOWN The interface is administratively disabled. Return Values If the function succeeds, the return value is NO_ERROR.If the function fails, use FormatMessage to obtain the message string for the returned error.Requirements Windows NT/2000/XP: Included in Windows NT 4.0 SP4 and later. Windows 95/98/Me: Included in Windows 98 and later. Header: Declared in Iphlpapi.h. Library: Use Iphlpapi.lib.
方法2: 关闭所有网卡: 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[I]; 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; 试试行不行啊。不过禁用网卡是比较好的选择。
Proxy,ISA,WinGate 或SysGate
sysGate(为了让局域网内的机子访问互联网)
天网防火墙(随意控制局域网内的机子访问互联网--想让谁上就让谁上;增强网络安全)
如果你感觉这个合适你,请回短消息,我在对给你,呵呵,交流嘛
用IphlpApi中的函数
Platform SDK: Internet Protocol Helper SetIfEntryUse the SetIfEntry function to set the administrative status of an interface.
DWORD SetIfEntry(
PMIB_IFROW pIfRow
);Parameters
pIfRow
[in] Pointer to a MIB_IFROW structure. The dwIndex member of this structure specifies the interface on which to set administrative status. The dwAdminStatus member specifies the new administrative status. The dwAdminStatus member can be one of the following values. Value Meaning
MIB_IF_ADMIN_STATUS_UP The interface is administratively enabled.
MIB_IF_ADMIN_STATUS_DOWN The interface is administratively disabled. Return Values
If the function succeeds, the return value is NO_ERROR.If the function fails, use FormatMessage to obtain the message string for the returned error.Requirements
Windows NT/2000/XP: Included in Windows NT 4.0 SP4 and later.
Windows 95/98/Me: Included in Windows 98 and later.
Header: Declared in Iphlpapi.h.
Library: Use Iphlpapi.lib.
关闭所有网卡:
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[I];
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;
试试行不行啊。不过禁用网卡是比较好的选择。