Commit 275f803b authored by zhanglongtao's avatar zhanglongtao

no message

parent 1bfba870
using System;
using System.Collections.Generic;
using System.Management;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
namespace HYH.Registry.Services.Encryption
......@@ -52,7 +54,7 @@ namespace HYH.Registry.Services.Encryption
///
/// </summary>
/// <returns></returns>
public static string GetName()
public static string GetHostName()
{
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
//获取本机电脑名
......@@ -113,16 +115,9 @@ namespace HYH.Registry.Services.Encryption
/// <returns></returns>
public static string GetMACIp()
{
//本地计算机网络连接信息
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
//获取本机所有网络连接
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
//获取本机电脑名
var HostName = computerProperties.HostName;
//获取域名
var DomainName = computerProperties.DomainName;
if (nics == null || nics.Length < 1)
{
return "";
......@@ -151,20 +146,40 @@ namespace HYH.Registry.Services.Encryption
}
}
//}
MACIp += "[" + adapterName + ":" + macip + "] ";
MACIp += "[" + adapterName + ":" + macip + "-" + adapterDescription + "-" + NetworkInterfaceType + "] ";
}
return MACIp;
}
//public static string GetHostName()
//{
// //获取本机所有网络连接
// NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
// foreach (NetworkInterface adapter in nics)
// {
// var fdd = adapter.GetIPProperties();
// fdd.GetIPv4Properties
// }
//}
//public static string GetIPv4()
//{
//获取内网IP
public static IPAddress GetInternalIP()
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
public static string GetHostName()
foreach (NetworkInterface adapter in nics)
{
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
//获取本机电脑名
var HostName = computerProperties.HostName;
////获取域名
//var DomainName = computerProperties.DomainName;
return "电脑名:" + HostName;
foreach (var uni in adapter.GetIPProperties().UnicastAddresses)
{
if (uni.Address.AddressFamily == AddressFamily.InterNetwork)
{
return uni.Address;
}
}
}
return null;
}
//}
}
}
......@@ -84,7 +84,7 @@ namespace HYH.Registry.Services.Encryption
[HttpGet]
public string GetName()
{
string netCardMACAddress = ComputerInfoHelper.GetName();
string netCardMACAddress = ComputerInfoHelper.GetHostName();
return netCardMACAddress;
}
/// <summary>
......@@ -160,5 +160,16 @@ namespace HYH.Registry.Services.Encryption
}
return new JsonResult(flag);
}
/// <summary>
/// 获取内网ip
/// </summary>
/// <returns></returns>
public async Task<object> GetInternalIP()
{
var InternalIP = ComputerInfoHelper.GetInternalIP();
return InternalIP.ToString();
}
}
}
......@@ -37,7 +37,7 @@
<param name="Vector">向量</param>
<returns>明文</returns>
</member>
<member name="M:HYH.Registry.Services.Encryption.ComputerInfoHelper.GetName">
<member name="M:HYH.Registry.Services.Encryption.ComputerInfoHelper.GetHostName">
<summary>
</summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment