首页 > 其他 > 详细

c#获取电脑内部信息

时间:2014-07-14 11:09:46      阅读:169      评论:0      收藏:0      [点我收藏+]

        /// <summary>
        /// 得到电脑CPU序列号
        /// </summary>
        public string GetComputerCPUSerialNo()
        {
            string cpuSerialNo = string.Empty;
            System.Management.ManagementClass managementClass = new System.Management.ManagementClass("Win32_Processor");
            System.Management.ManagementObjectCollection managementObjectCollection = managementClass.GetInstances();
            foreach (System.Management.ManagementObject managementObject in managementObjectCollection)
            {
                cpuSerialNo = managementObject.Properties["ProcessorId"].Value.ToString();
                break;
            }
            return cpuSerialNo;
        }

 

    

        /// <summary>
        /// 得到客户端IP地址
        /// </summary>
        public string GetClientIdAddress()
        {
            string ip = string.Empty;
            try
            {
                if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_ForWARDED_For"] == null)
                    ip = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
                else
                    ip = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_ForWARDED_For"].ToString();

                if (string.IsNullOrEmpty(ip)) {
                    ip = System.Web.HttpContext.Current.Request.UserHostAddress;
                }
            }
            catch { ip = "1.1.1.1"; }
            return ip;
        }

 

c#获取电脑内部信息,布布扣,bubuko.com

c#获取电脑内部信息

原文:http://blog.csdn.net/y_f123/article/details/37742049

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!