C#獲取本機(jī)信息
當(dāng)前位置:點(diǎn)晴教程→知識管理交流
→『 技術(shù)文檔交流 』
/// <summary>
/// 獲得本機(jī)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> /// 獲得本機(jī)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> /// 獲取系統(tǒng)版本 /// </summary> /// <returns></returns> public string GetOSVersion() { OperatingSystem osInfo = Environment.OSVersion; string version = osInfo.Version.ToString(); return version; } /// <summary> /// 獲得系統(tǒng)分辨率 /// </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; } 該文章在 2021/1/29 17:06:24 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |