C# winfrom 获取本地IP地址,主机名:(using System.Net;)
string hostName = Dns.GetHostName(); //获取本机名
IPHostEntry localhost = Dns.GetHostByName(hostName); //可以获取IPv4的地址
//IPHostEntry localhost = Dns.GetHostEntry(hostName); //获取IPv6地址
IPAddress localaddr = localhost.AddressList[0];
string Address = localaddr.ToString();
C# 获取电脑屏幕中间点
Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);
int width = ScreenArea.Width;
int height = ScreenArea.Height;
//this.Location = new Point((width - this.Width) / 2, (height - this.Height) / 2);