用Delphi编写邮件特快专递程序(二)

Indy 9自带demo “DNSResolver Client” 编译通不过。

这个 Demos 确实是有错的(主要是因为 TQueryResult 的 Items[Index] TResultRecord 有很多继承类的问题造成的),我已经修改完了,供参考。

procedure TForm1.acRunExecute(Sender: TObject);
var
i: integer;
begin
IdDNSResolver.Active := true;
IdDNSResolver.Resolve(edQuery.text);
IdDNSResolver.Active := false;
for i := 0 to IdDNSResolver.QueryResult.Count – 1 do
begin
case IdDNSResolver.QueryResult[i].RecType of
qtA:
begin
memoResult.Lines.Append(‘A:’);
memoResult.Lines.Append(‘ Domain Name: ‘ + TARecord(IdDNSResolver.QueryResult[i]).IPAddress);
end;
qtName:
begin
memoResult.Lines.Append(‘Name’);
memoResult.Lines.Append(‘ Name: ‘ + TNAMERecord(IdDNSResolver.QueryResult[i]).HostName);
end;
qtPTR:
begin
memoResult.Lines.Append(‘PTR:’);
memoResult.Lines.Append(‘ PTR: ‘ + TPTRRecord(IdDNSResolver.QueryResult[i]).HostName);
end;
qtMX:
begin
memoResult.Lines.Append(‘MX’);
memoResult.Lines.Append(‘ Exchange: ‘ + TMXRecord(IdDNSResolver.QueryResult[i]).ExchangeServer);
memoResult.Lines.Append(‘ preference: ‘ + IntToStr(TMXRecord(IdDNSResolver.QueryResult[i]).Preference));
end;
qtSOA:
begin
memoResult.Lines.Append(‘SOA’);
memoResult.Lines.Append(‘ Expire: ‘ + IntToStr(TSOARecord(IdDNSResolver.QueryResult[i]).Expire));
memoResult.Lines.Append(‘ Minimum: ‘ + IntToStr(TSOARecord(IdDNSResolver.QueryResult[i]).MinimumTTL));
memoResult.Lines.Append(‘ MName: ‘ + TSOARecord(IdDNSResolver.QueryResult[i]).Primary);
memoResult.Lines.Append(‘ Refresh: ‘ + IntToStr(TSOARecord(IdDNSResolver.QueryResult[i]).Refresh));
memoResult.Lines.Append(‘ Retry: ‘ + IntToStr(TSOARecord(IdDNSResolver.QueryResult[i]).Retry));
memoResult.Lines.Append(‘ RName: ‘ + TSOARecord(IdDNSResolver.QueryResult[i]).ResponsiblePerson);
memoResult.Lines.Append(‘ Serial: ‘ + IntToStr(TSOARecord(IdDNSResolver.QueryResult[i]).Serial));
end;
qtWKS:
begin
memoResult.Lines.Append(‘WKS’);
memoResult.Lines.Append(‘ Address: ‘ + TWKSRecord(IdDNSResolver.QueryResult[i]).Address);
memoResult.Lines.Append(‘ Protocol: ‘ + IntToStr(TWKSRecord(IdDNSResolver.QueryResult[i]).Protocol));
memoResult.Lines.Append(‘ Bytes: ‘ + Format(‘%d %d %d %d %d %d %d %d’,
[(IdDNSResolver.QueryResult[i] as TWKSRecord).BitMap[0],
(IdDNSResolver.QueryResult[i] as TWKSRecord).BitMap[1],
(IdDNSResolver.QueryResult[i] as TWKSRecord).BitMap[2],
(IdDNSResolver.QueryResult[i] as TWKSRecord).BitMap[3],
(IdDNSResolver.QueryResult[i] as TWKSRecord).BitMap[4],
(IdDNSResolver.QueryResult[i] as TWKSRecord).BitMap[5],
(IdDNSResolver.QueryResult[i] as TWKSRecord).BitMap[6],
(IdDNSResolver.QueryResult[i] as TWKSRecord).BitMap[7]]
));
end;
qtHINFO:
begin
memoResult.Lines.Append(‘HINFO’);
memoResult.Lines.Append(‘ CPU: ‘ + (IdDNSResolver.QueryResult[i] as THInfoRecord).CPU);
memoResult.Lines.Append(‘ Os: ‘ + (IdDNSResolver.QueryResult[i] as THInfoRecord).CPU);
end;
qtMINFO:
begin
memoResult.Lines.Append(‘MINFO:’);
memoResult.Lines.Append(‘ Errors MailBox: ‘ + (IdDNSResolver.QueryResult[i] as TMInfoRecord).ErrorMailbox);
memoResult.Lines.Append(‘ Responsible persone MailBox: ‘ + (IdDNSResolver.QueryResult[i] as TMInfoRecord).ResponsiblePersonMailbox);
end;
qtNS:
begin
memoResult.Lines.Append(‘NS:’);
memoResult.Lines.Append(‘ Name server: ‘ + TNSRecord(IdDNSResolver.QueryResult[i]).HostName);
end;
else
begin
memoResult.Lines.Append(‘Other:’);
memoResult.Lines.Append(‘ Data: ‘ + (IdDNSResolver.QueryResult[i]).RData);
end;
end;
memoResult.Lines.Append(‘ TTL: ‘ + IntToStr(IdDNSResolver.QueryResult[i].TTL));
end;
end;



发表评论

电子邮件地址不会被公开。 必填项已用*标注

34 − 26 =