p; Console.WriteLine(\"网卡编号=\" + getInfo.GetNetworkAdapterId());
Console.WriteLine(\"用户组=\" + getInfo.GetGroupName());
Console.WriteLine(\"驱动器情况=\" + getInfo.GetDriverInfo());
Console.ReadLine();
}
}
}由于是一个命令行程序,所以有上面那个类,下面这个类才包含我要展示的代码:[Page]
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace WMIDemo
{
/// <summary>
/// 说明:这个类主要用来展示如何利用WMI来获取一些操作系统的信息
/// 作者:周公
/// 时间:2008-1-14
/// 首发地址:http://blog.csdn.net/zhoufoxcn
/// </summary>
public class GetSystemInfo
{
/// <summary>
/// 获取操作系统序列号
/// </summary>
/// <returns></returns>
public string GetSerialNumber()
{
string result = \"\";
ManagementClass mClass = new ManagementClass(\"Win32_OperatingSystem\");
ManagementObjectCollection moCollection = mClass.GetInstances();
foreach (ManagementObject mObject in moCollection)
{
result += mObject[\"SerialNumber\"].ToString() + \" \";
}
return result;
}
/// <summary>
/// 查询CPU编号
/// </summary>
/// <returns&g