/// <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;
}