当前位置: 代码迷 >> 综合 >> 随手
  详细解决方案

随手

热度:60   发布时间:2023-09-28 06:58:32.0

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);

 

  相关解决方案