using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Sockets; using System.Net.NetworkInformation; namespace Shared { [System.Serializable] public static class Global { /// /// ±¾µØ×ÓÍøºÅ /// public static readonly byte LocalSubnetID = 252; /// /// ±¾µØÉ豸ºÅ /// public static readonly byte LocalDeviceID = 252; /// /// ±¾µØÉ豸ÀàÐÍ /// public static readonly int DeviceType = 0xFFFC; /// /// »ñÈ¡µ±Ç°wifiµÄIPµØÖ· /// /// public static string IpAddress { get { foreach (var networkInterface in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()) { foreach (var unicastAddresses in networkInterface.GetIPProperties().UnicastAddresses) { if (unicastAddresses.Address.AddressFamily == AddressFamily.InterNetwork && unicastAddresses.Address.ToString() != "127.0.0.1") { return unicastAddresses.Address.ToString(); } } } return "127.0.0.1"; } } } }