Commit 275f803b authored by zhanglongtao's avatar zhanglongtao

no message

parent 1bfba870
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Management; using System.Management;
using System.Net;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text; using System.Text;
namespace HYH.Registry.Services.Encryption namespace HYH.Registry.Services.Encryption
...@@ -52,7 +54,7 @@ namespace HYH.Registry.Services.Encryption ...@@ -52,7 +54,7 @@ namespace HYH.Registry.Services.Encryption
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static string GetName() public static string GetHostName()
{ {
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
//获取本机电脑名 //获取本机电脑名
...@@ -113,16 +115,9 @@ namespace HYH.Registry.Services.Encryption ...@@ -113,16 +115,9 @@ namespace HYH.Registry.Services.Encryption
/// <returns></returns> /// <returns></returns>
public static string GetMACIp() public static string GetMACIp()
{ {
//本地计算机网络连接信息
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
//获取本机所有网络连接 //获取本机所有网络连接
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
//获取本机电脑名
var HostName = computerProperties.HostName;
//获取域名
var DomainName = computerProperties.DomainName;
if (nics == null || nics.Length < 1) if (nics == null || nics.Length < 1)
{ {
return ""; return "";
...@@ -151,20 +146,40 @@ namespace HYH.Registry.Services.Encryption ...@@ -151,20 +146,40 @@ namespace HYH.Registry.Services.Encryption
} }
} }
//} //}
MACIp += "[" + adapterName + ":" + macip + "] "; MACIp += "[" + adapterName + ":" + macip + "-" + adapterDescription + "-" + NetworkInterfaceType + "] ";
} }
return MACIp; return MACIp;
} }
//public static string GetHostName()
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()
{ {
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
//获取本机电脑名
var HostName = computerProperties.HostName; foreach (NetworkInterface adapter in nics)
////获取域名 {
//var DomainName = computerProperties.DomainName; foreach (var uni in adapter.GetIPProperties().UnicastAddresses)
return "电脑名:" + HostName; {
if (uni.Address.AddressFamily == AddressFamily.InterNetwork)
{
return uni.Address;
}
}
}
return null;
} }
//}
} }
} }
...@@ -84,7 +84,7 @@ namespace HYH.Registry.Services.Encryption ...@@ -84,7 +84,7 @@ namespace HYH.Registry.Services.Encryption
[HttpGet] [HttpGet]
public string GetName() public string GetName()
{ {
string netCardMACAddress = ComputerInfoHelper.GetName(); string netCardMACAddress = ComputerInfoHelper.GetHostName();
return netCardMACAddress; return netCardMACAddress;
} }
/// <summary> /// <summary>
...@@ -160,5 +160,16 @@ namespace HYH.Registry.Services.Encryption ...@@ -160,5 +160,16 @@ namespace HYH.Registry.Services.Encryption
} }
return new JsonResult(flag); 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 @@ ...@@ -37,7 +37,7 @@
<param name="Vector">向量</param> <param name="Vector">向量</param>
<returns>明文</returns> <returns>明文</returns>
</member> </member>
<member name="M:HYH.Registry.Services.Encryption.ComputerInfoHelper.GetName"> <member name="M:HYH.Registry.Services.Encryption.ComputerInfoHelper.GetHostName">
<summary> <summary>
</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