/// <summary> /// 得到本機IP /// </summary> /// <returns></returns> public string GetIP() { string IP = null; string hostName = Dns.GetHostName(); IPHostEntry ipEntry = Dns.GetHostEntry(hostName); foreach (IPAddress ip in ipEntry.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { IP = ip.ToString(); } } return IP; } /// <summary> /// 得到本機Mac /// </summary> /// <returns></returns> public string GetMac() { string mac = null; var interfaces = NetworkInterface.GetAllNetworkInterfaces(); if (interfaces.Length > 0) { mac = interfaces[0].GetPhysicalAddress().ToString(); if (mac.Length > 21) { mac = mac.Substring(0, 21); } } return mac; } /// <summary> /// 獲取系統版本 /// </summary> /// <returns></returns> public string GetOSVersion() { OperatingSystem osInfo = Environment.OSVersion; string version = osInfo.Version.ToString(); return version; } /// <summary> /// 得到系統分辨率 /// </summary> /// <returns></returns> public string GetResolution() { int SW = Screen.PrimaryScreen.Bounds.Width; int SH = Screen.PrimaryScreen.Bounds.Height; string resolution = SW.ToString() + "*" SH.ToString(); return resolution; }