码迷,mamicode.com
首页 > 移动开发 > 详细

c# 获取 bios 序列号

时间:2018-08-30 14:28:03      阅读:824      评论:0      收藏:0      [点我收藏+]

标签:console   .text   namespace   val   pac   class   nbsp   win   sea   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using System.Diagnostics;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Debug.Print(getBiosSN());

        }

        public static string getBiosSN()
        {
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_BIOS");
            ManagementObjectCollection objects = searcher.Get();
            foreach (ManagementObject obj in objects)
            {
                try
                {
                    if (obj.GetPropertyValue("SerialNumber") != null)
                    {
                        return obj["SerialNumber"].ToString();
                    }
                }
                catch (Exception)
                {
                }
            }

            return string.Empty;
        }
    }
}

 

c# 获取 bios 序列号

标签:console   .text   namespace   val   pac   class   nbsp   win   sea   

原文地址:https://www.cnblogs.com/nanfei/p/9559699.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!