怎样通过程序动态重载dns服务器的主机信息? ( 积分: 100 )

  • 主题发起人 主题发起人 fanren945
  • 开始时间 开始时间
F

fanren945

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样通过程序动态重载dns服务器的主机信息?
 
怎样通过程序动态重载dns服务器的主机信息?
 
现在对动态域名软件有点兴趣,哪位大大给点资料和提示什么的阿?[:(!]
 
怎样通过程序动态重载dns服务器的主机信息?
 
Unit Udns;

interface

uses windows, sysutils, Classes;

const
MAX_HOSTNAME_LEN = 128; { from IPTYPES.H }
MAX_DOMAIN_NAME_LEN = 128;
MAX_SCOPE_ID_LEN = 256;
MAX_ADAPTER_NAME_LENGTH = 256;
MAX_ADAPTER_DESCRIPTION_LENGTH = 128;
MAX_ADAPTER_ADDRESS_LENGTH = 8;

type
TIPAddressString = array[0..4 * 4 - 1] of Char;

PIPAddrString = ^TIPAddrString;
TIPAddrString = record
Next: PIPAddrString;
IPAddress: TIPAddressString;
IPMask: TIPAddressString;
Context: Integer;
end;

PFixedInfo = ^TFixedInfo;
TFixedInfo = record { FIXED_INFO }
HostName: array[0..MAX_HOSTNAME_LEN + 3] of Char;
DomainName: array[0..MAX_DOMAIN_NAME_LEN + 3] of Char;
CurrentDNSServer: PIPAddrString;
DNSServerList: TIPAddrString;
NodeType: Integer;
ScopeId: array[0..MAX_SCOPE_ID_LEN + 3] of Char;
EnableRouting: Integer;
EnableProxy: Integer;
EnableDNS: Integer;
end;


function GetDNSList(aDNSList: tstringlist): boolean;
function GetNetworkParams(FI: PFixedInfo; var BufLen: Integer): Integer; stdcall; external 'iphlpapi.dll';

implementation

function GetDNSList(aDnsList: tstringlist): boolean;
var
FI: PFixedInfo;
Size: Integer;
Res: Integer;
// I: Integer;
DNS: PIPAddrString;
begin
Size := 1024;
GetMem(FI, Size);
Res := GetNetworkParams(FI, Size);
if (Res <> ERROR_SUCCESS) then begin
result := false;
SetLastError(Res);
// RaiseLastWin32Error;
exit;
end;
aDnsList.Clear;
// I := 1;
DNS := @FI^.DNSServerList;
repeat
aDnsList.Add(DNS^.IPAddress);
// Inc(I);
DNS := DNS^.Next;
until (DNS = nil);
FreeMem(FI);
result := true;
end;

end.
 
TO phzongna:
我可能说的不清楚 呵呵,是DNS服务器不是我的电脑上的 DNS域的主机信息~~~
TO jingtao:
感谢所提供的CODE,我研究研究哈 THX THX THX ~~`
 
后退
顶部