用IP Helper API实现修改路由,有朋友有这方面的例子吗?(200分)

L

lovenuo

Unregistered / Unconfirmed
GUEST, unregistred user!
用IP Helper API实现修改路由
在网上找到了一个Route的原代码,里面的增加功能用不了,不知道为什么。
有朋友有这方面的例子,请留言。谢谢。
有的可以直接联系我QQ,一般,一直在线的,我的QQ 89993651
小妹,在这里先谢谢了.
 
帮我看一下面的代码,运行后,老是提示.Invalid parameter 不知道那里出错了.
procedure CreateIpEntry(Destination, Mask, Gateway, Metric, aIfNo: string;
Persistent: boolean);
var
Route: TMibIpForwardRow;
Res: DWORD;
IfNo: DWORD;
// The interface number
begin
if Metric = '' then
Metric := '1';
IfNo := DWORD(-1);
if aIfNo = '' then
begin
Res := GetBestInterface(inet_addr(PChar(GateWay)), IfNo);
case Res of
ERROR_SUCCESS: ;
ERROR_NOT_SUPPORTED:
WriteLn(Format(sNotSupported, ['GetBestInterface']));
ERROR_CAN_NOT_COMPLETE:
WriteLn(Format(sCanNotComplete, ['GetBestInterface']));
else
WriteLn(SysErrorMessage(GetLastError));
end;
end
else
IfNo := StrToIntDef(aIfNo, -1);
if IfNo = DWORD(-1) then
begin
WriteLn('Interface is not found.');
Exit;
end;

FillChar(Route, SizeOf(Route), #0);
with Routedo
begin
dwForwardDest := inet_addr(PChar(Destination));
dwForwardMask := inet_addr(PChar(Mask));
dwForwardPolicy := 0;
// Should be zero from Microsoft Help
dwForwardNextHop := inet_addr(PChar(Gateway));
dwForwardIfIndex := IfNo;
dwForwardType := 3;
//The next hop is the final destination (local route).
dwForwardProto := 3;
// PROTO_IP_NETMGMT from Microsoft Help (const in Routprot.h)
dwForwardAge := 0;
dwForwardNextHopAS := 0;
dwForwardMetric1 := StrToIntDef(Metric, 1);
dwForwardMetric2 := DWORD(-1);
dwForwardMetric3 := DWORD(-1);
dwForwardMetric4 := DWORD(-1);
dwForwardMetric5 := DWORD(-1);
end;
Res := CreateIpForwardEntry(Route);
case Res of
NO_ERROR:
if Persistent then
SavePersistentRoute(Destination + ',' + Mask + ',' + Gateway + ',' + Metric, Chr(10));
ERROR_INVALID_PARAMETER:
WriteLn('Invalid parameter');
ERROR_NOT_SUPPORTED:
WriteLn('The IP transport is not configured on the local computer.');
else
WriteLn(SysErrorMessage(GetLastError));
end;
end;
 
这就是所谓的占着茅坑不拉屎。[:D]
 
你想要屎呀,等着,我这就拉给你。[:D]
看了一下你资料,分数很高呀。。。。
 
世上无聊的人多,可没有人象你这样无聊的!
闲人一个,鉴定完毕[:D]
 

Similar threads

D
回复
0
查看
736
DelphiTeacher的专栏
D
D
回复
0
查看
713
DelphiTeacher的专栏
D
顶部