using System;
using System.Net;
using System.Net.Sockets;
namespace GetIpByDomain
{
/// <summary>
/// Class1 的摘要說明.
/// </summary> class Class1
{
/// <summary>
/// 應用程序的主入口點.
/// </summary> [STAThread] static void Main( string[] args )
{
//
// TODO: 在此處添加代碼以啟動應用程序
//
if( args.Length <= 0 ) { Console.Write( "\nGetIpByDomain V1.0 by ∮明天去要飯 QQ:305725744\n" );
Console.Write( "Usage:\n" );
Console.Write( " GetIpByDomain.exe <Domain>\n" );
Console.Write( "Example:\n" );
Console.Write( " GetIpByDomain.exe Www.ToEmpire.Com" );
}
else
{
string strDomain = args[0].ToString( );
IPHostEntry hostEntry = Dns.Resolve( strDomain );
IPEndPo
int ipEndPo
int = new IPEndPo
int(hostEntry.AddressList[0],0 );
//這就是你想要的
string ipAddress = ipEndPo
int.Address.ToString( );
Console.Write( ipAddress );
}
}
}
}
我只是簡單的實現一下,有興趣的朋友可以改改Bug.