One of the many namespaces in the Base Class Framework is the System.Net namespace. It provides a simple programming interface to many of the protocols found on the network today. One of the classes of the namespace is DNS which provides simple domain name resolution functionality.
{$APPTYPE CONSOLE}
program getip;uses
System,
System.Net,
Borland.Delphi.SysUtils;var
strMachineName : String;
ipHost : IPHostEntry;
ipAddr : array of IPAddress;
count : Integer;
begin
//Get the Host Name
strMachineName := Dns.GetHostName();
Console.WriteLine('Host Name: ' + strMachineName); //Get the Host by Name
ipHost := Dns.GetHostByName(strMachineName); //You can also query the DNS database for info on a
//website like users.chello.be
//In that case replace the above line as:
//ipHost := Dns.GetHostByName('users.chello.be') //Get the list of addresses associated with the host in an array
ipAddr := ipHost.AddressList; //Enumerate the IP Addresses
For count := 0 To length(ipAddr) - 1 do Console.Write(Format('IP Addresses %d: %s ', [count, ipAddr[count].ToString]));
end.
来自http://users.chello.be/ws36637/getip.html
{$APPTYPE CONSOLE}
program getip;uses
System,
System.Net,
Borland.Delphi.SysUtils;var
strMachineName : String;
ipHost : IPHostEntry;
ipAddr : array of IPAddress;
count : Integer;
begin
//Get the Host Name
strMachineName := Dns.GetHostName();
Console.WriteLine('Host Name: ' + strMachineName); //Get the Host by Name
ipHost := Dns.GetHostByName(strMachineName); //You can also query the DNS database for info on a
//website like users.chello.be
//In that case replace the above line as:
//ipHost := Dns.GetHostByName('users.chello.be') //Get the list of addresses associated with the host in an array
ipAddr := ipHost.AddressList; //Enumerate the IP Addresses
For count := 0 To length(ipAddr) - 1 do Console.Write(Format('IP Addresses %d: %s ', [count, ipAddr[count].ToString]));
end.
来自http://users.chello.be/ws36637/getip.html
解决方案 »
- delphi访问oracle9i表里char字段的问题
- delphi2005中键盘与鼠标触发事件的问题
- ole型字段如何创建?SQL.Add('EMIT_IMG ole,')对么?再线等!
- 那里有TMSComm这个东西可下载?
- Delphi最高版本是几点零? 下一版本是.net吗? 有中文版吗?
- 简单问题:解决即结贴
- 怎样实现ListView的上 滚和下 滚 功能?100分
- 请假一个字符串操作函数
- 关于在delphi中涉及日期条件sql语句的写法问题
- 请问怎么用delphi把avi格式文件转成wma格式的啊
- 請問? 在線等 馬上結貼
- 请教多个HTML页面同时调用一个activeForm时出现的问题
学习!顶