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; 没弄过,一点参考资料,
我想调用IP助手函数库,用iprenewaddress函数从DHCP服务器重新分配上网需要的一些信息。
但不知道在delphi下应该如何调用。谁能给讲讲!!!???
谢谢!
procedure/function IPRenewAddress(...)...; external; 'c:\winnt\system32\iphlpapi.dll' ??
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;
没弄过,一点参考资料,