• 获取本机ID和电脑名称


    1.获取本机IP

     /// <summary>
            /// 获取本机所有IPV4地址列表e799bee5baa6e4b893e5b19e31333330343831
            /// </summary>
            /// <returns>本机所有IPV4地址列表,以分号分隔</returns>
            public static string GetSelfIpv4List()
            {
                StringBuilder ips = new StringBuilder();
                try
                {
                    IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
                    foreach (IPAddress ipa in IpEntry.AddressList)
                    {
                        if (ipa.AddressFamily == AddressFamily.InterNetwork)
                            ips.AppendFormat("{0};", ipa.ToString());
                    }
                }
                catch (Exception ex)
                {
                }
                return ips.ToString();
            }

    2.获取本机名称

    ///System.Net
    Dns.GetHostName();

     

  • 相关阅读:
    ASP.NET初识4
    属性
    ASP.NET初识4
    ACCP6.0第九章练习
    ASP.NET初识1
    鼠标指针含义
    ASP.NET初识2
    第三部分
    ASP.NET初识3
    ASP.NET初识5
  • 原文地址:https://www.cnblogs.com/yuanshuo/p/12966238.html
Copyright © 2020-2023  润新知