using system.net
IPHostEntry ipe = Dns.GetHostEntry(Dns.GetHostName()); IPAddress ipa = ipe.AddressList[3]; txtIP.Text = ipa.ToString();
本机ip
原文:http://www.cnblogs.com/mfleven/p/3541466.html