在delphi下如何调用iphlpapi.dll中的iprenewaddress函数实现IP地址重新分配!?

hdboy 2003-11-22 02:52:08
我想调用c:\winnt\system32\iphlpapi.dll文件,用里面的iprenewaddress函数从dhcp服务器重新配置网络信息,请问,具体如何实现!??
最好能给写个简单的例程。谢谢~!
...全文
356 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hongqi162 2003-11-27
  • 打赏
  • 举报
回复
const
iphlpapilib = 'iphlpapi.dll';

{$IFNDEF IPHLPAPI_DYNLINK}

function GetNumberOfInterfaces; external iphlpapilib name 'GetNumberOfInterfaces';
function GetIfEntry; external iphlpapilib name 'GetIfEntry';
function GetIfTable; external iphlpapilib name 'GetIfTable';
function GetIpAddrTable; external iphlpapilib name 'GetIpAddrTable';
function GetIpNetTable; external iphlpapilib name 'GetIpNetTable';
function GetIpForwardTable; external iphlpapilib name 'GetIpForwardTable';
function GetTcpTable; external iphlpapilib name 'GetTcpTable';
function GetUdpTable; external iphlpapilib name 'GetUdpTable';
function GetIpStatistics; external iphlpapilib name 'GetIpStatistics';
function GetIcmpStatistics; external iphlpapilib name 'GetIcmpStatistics';
function GetTcpStatistics; external iphlpapilib name 'GetTcpStatistics';
function GetUdpStatistics; external iphlpapilib name 'GetUdpStatistics';
function SetIfEntry; external iphlpapilib name 'SetIfEntry';
function CreateIpForwardEntry; external iphlpapilib name 'CreateIpForwardEntry';
function SetIpForwardEntry; external iphlpapilib name 'SetIpForwardEntry';
function DeleteIpForwardEntry; external iphlpapilib name 'DeleteIpForwardEntry';
function SetIpStatistics; external iphlpapilib name 'SetIpStatistics';
function SetIpTTL; external iphlpapilib name 'SetIpTTL';
function CreateIpNetEntry; external iphlpapilib name 'CreateIpNetEntry';
function SetIpNetEntry; external iphlpapilib name 'SetIpNetEntry';
function DeleteIpNetEntry; external iphlpapilib name 'DeleteIpNetEntry';
function FlushIpNetTable; external iphlpapilib name 'FlushIpNetTable';
function CreateProxyArpEntry; external iphlpapilib name 'CreateProxyArpEntry';
function DeleteProxyArpEntry; external iphlpapilib name 'DeleteProxyArpEntry';
function SetTcpEntry; external iphlpapilib name 'SetTcpEntry';
function GetInterfaceInfo; external iphlpapilib name 'GetInterfaceInfo';
function GetUniDirectionalAdapterInfo; external iphlpapilib name 'GetUniDirectionalAdapterInfo';
function GetBestInterface; external iphlpapilib name 'GetBestInterface';
function GetBestRoute; external iphlpapilib name 'GetBestRoute';
function NotifyAddrChange; external iphlpapilib name 'NotifyAddrChange';
function NotifyRouteChange; external iphlpapilib name 'NotifyRouteChange';
function GetAdapterIndex; external iphlpapilib name 'GetAdapterIndex';
function AddIPAddress; external iphlpapilib name 'AddIPAddress';
function DeleteIPAddress; external iphlpapilib name 'DeleteIPAddress';
function GetNetworkParams; external iphlpapilib name 'GetNetworkParams';
function GetAdaptersInfo; external iphlpapilib name 'GetAdaptersInfo';
function GetPerAdapterInfo; external iphlpapilib name 'GetPerAdapterInfo';
function IpReleaseAddress; external iphlpapilib name 'IpReleaseAddress';
function IpRenewAddress; external iphlpapilib name 'IpRenewAddress';
function SendARP; external iphlpapilib name 'SendARP';
function GetRTTAndHopCount; external iphlpapilib name 'GetRTTAndHopCount';
function GetFriendlyIfIndex; external iphlpapilib name 'GetFriendlyIfIndex';
function EnableRouter; external iphlpapilib name 'EnableRouter';
function UnenableRouter; external iphlpapilib name 'UnenableRouter';

{$ELSE}

var
HIpHlpApi: THandle = 0;

function IpHlpApiInitAPI: Boolean;
begin
Result := False;
if HIphlpapi = 0 then HIpHlpApi := LoadLibrary(iphlpapilib);
if HIpHlpApi > HINSTANCE_ERROR then
begin
@GetNetworkParams := GetProcAddress(HIpHlpApi, 'GetNetworkParams');
@GetAdaptersInfo := GetProcAddress(HIpHlpApi, 'GetAdaptersInfo');
@GetPerAdapterInfo := GetProcAddress(HIpHlpApi, 'GetPerAdapterInfo');
@GetAdapterIndex := GetProcAddress(HIpHlpApi, 'GetAdapterIndex');
@GetUniDirectionalAdapterInfo := GetProcAddress(HIpHlpApi, 'GetUniDirectionalAdapterInfo');
@GetNumberOfInterfaces := GetProcAddress(HIpHlpApi, 'GetNumberOfInterfaces');
@GetInterfaceInfo := GetProcAddress(HIpHlpApi, 'GetInterfaceInfo');
@GetFriendlyIfIndex := GetProcAddress(HIpHlpApi, 'GetFriendlyIfIndex');
@GetIfTable := GetProcAddress(HIpHlpApi, 'GetIfTable');
@GetIfEntry := GetProcAddress(HIpHlpApi, 'GetIfEntry');
@SetIfEntry := GetProcAddress(HIpHlpApi, 'SetIfEntry');
@GetIpAddrTable := GetProcAddress(HIpHlpApi, 'GetIpAddrTable');
@AddIPAddress := GetProcAddress(HIpHlpApi, 'AddIPAddress');
@DeleteIPAddress := GetProcAddress(HIpHlpApi, 'DeleteIPAddress');
@IpReleaseAddress := GetProcAddress(HIpHlpApi, 'IpReleaseAddress');
@IpRenewAddress := GetProcAddress(HIpHlpApi, 'IpRenewAddress');
@GetIpNetTable := GetProcAddress(HIpHlpApi, 'GetIpNetTable');
@CreateIpNetEntry := GetProcAddress(HIpHlpApi, 'CreateIpNetEntry');
@DeleteIpNetEntry := GetProcAddress(HIpHlpApi, 'DeleteIpNetEntry');
@CreateProxyArpEntry := GetProcAddress(HIpHlpApi, 'CreateProxyArpEntry');
@DeleteProxyArpEntry := GetProcAddress(HIpHlpApi, 'DeleteProxyArpEntry');
@SendARP := GetProcAddress(HIpHlpApi, 'SendARP');
@GetIpStatistics := GetProcAddress(HIpHlpApi, 'GetIpStatistics');
@GetIcmpStatistics := GetProcAddress(HIpHlpApi, 'GetIcmpStatistics');
@SetIpStatistics := GetProcAddress(HIpHlpApi, 'SetIpStatistics');
@SetIpTTL := GetProcAddress(HIpHlpApi, 'SetIpTTL');
@GetIpForwardTable := GetProcAddress(HIpHlpApi,'GetIpForwardTable');
@CreateIpForwardEntry := GetProcAddress(HIpHlpApi, 'CreateIpForwardEntry');
@GetTcpTable := GetProcAddress(HIpHlpApi, 'GetTcpTable');
@GetUdpTable := GetProcAddress(HIpHlpApi, 'GetUdpTable');
@GetTcpStatistics := GetProcAddress(HIpHlpApi, 'GetTcpStatistics');
@GetUdpStatistics := GetProcAddress(HIpHlpApi, 'GetUdpStatistics');
@SetIpForwardEntry := GetProcAddress(HIpHlpApi, 'SetIpForwardEntry');
@DeleteIpForwardEntry := GetProcAddress(HIpHlpApi, 'DeleteIpForwardEntry');
@SetIpNetEntry := GetProcAddress(HIpHlpApi, 'SetIpNetEntry');
@SetTcpEntry := GetProcAddress(HIpHlpApi, 'SetTcpEntry');
@GetBestRoute := GetProcAddress(HIpHlpApi, 'GetBestRoute');
@NotifyAddrChange := GetProcAddress(HIpHlpApi, 'NotifyAddrChange');
@NotifyRouteChange := GetProcAddress(HIpHlpApi, 'NotifyRouteChange');
@GetBestInterface := GetProcAddress(HIpHlpApi, 'GetBestInterface');
@GetRTTAndHopCount := GetProcAddress(HIpHlpApi, 'GetRTTAndHopCount');
@EnableRouter := GetProcAddress(HIpHlpApi, 'EnableRouter');
@UnenableRouter := GetProcAddress(HIpHlpApi, 'UnenableRouter');
Result := True;
end;
end;

procedure IpHlpApiFreeAPI;
begin
if HIpHlpApi <> 0 then FreeLibrary(HIpHlpApi);
HIpHlpApi := 0;
end;
没弄过,一点参考资料,
hdboy 2003-11-26
  • 打赏
  • 举报
回复
能不能具体点呀?
wengj 2003-11-25
  • 打赏
  • 举报
回复
?
procedure/function IPRenewAddress(...)...; external; 'c:\winnt\system32\iphlpapi.dll' ??
hdboy 2003-11-24
  • 打赏
  • 举报
回复
没人知道么!?
bottom 2003-11-23
  • 打赏
  • 举报
回复
太难了
hdboy 2003-11-23
  • 打赏
  • 举报
回复
看不懂我的问题!??
我想调用IP助手函数库,用iprenewaddress函数从DHCP服务器重新分配上网需要的一些信息。
但不知道在delphi下应该如何调用。谁能给讲讲!!!???
谢谢!
wengj 2003-11-22
  • 打赏
  • 举报
回复

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧