zoukankan      html  css  js  c++  java
  • C#如何编程方式获取计算机主板序列号

    建立一个控制台应用程序,添加对程序集System.Management的引用,代码如下:

     

    查看源码
     1 using System; 
    2 using System.Collections.Generic;
    3 using System.Text;
    4 using System.Management;
    5 namespace ConsoleApplication1
    6 {
    7 class Program
    8 {
    9 static void Main(string[] args)
    10 {
    11 PrintMotherBoardInfo();
    12 Console.WriteLine(GetMotherBoardSerialNumber());
    13 }
    14 /// <summary>
    15 /// 打印主板信息
    16 /// </summary>
    17 private static void PrintMotherBoardInfo()
    18 {
    19 ManagementClass mc = new ManagementClass("WIN32_BaseBoard");
    20 ManagementObjectCollection moc = mc.GetInstances();
    21 foreach (ManagementObject mo in moc)
    22 {
    23 foreach (PropertyData pd in mo.Properties)
    24 {
    25 Console.WriteLine(string.Format("{0}{1}{2}",pd.Name,"\t", pd.Value));
    26 }
    27 }
    28 }
    29 //获取主板序号
    30 private static string GetMotherBoardSerialNumber()
    31 {
    32 ManagementClass mc = new ManagementClass("WIN32_BaseBoard");
    33 ManagementObjectCollection moc = mc.GetInstances();
    34 string SerialNumber = "";
    35 foreach (ManagementObject mo in moc)
    36 {
    37 SerialNumber= mo["SerialNumber"].ToString();
    38 break;
    39 }
    40 return SerialNumber;
    41 }
    42 }
    43 }

    原文地址:http://blog.csdn.net/netcoder/archive/2008/11/11/3279001.aspx

  • 相关阅读:
    keepalived+httpd 高可用
    网卡绑定配置文件
    elk安装
    mysql数据库
    sed
    kvm
    日常巡检
    haproxy
    (6)PY_(study)
    (5)PY_(study)
  • 原文地址:https://www.cnblogs.com/shlcn/p/2112770.html
Copyright © 2011-2022 走看看