取得硬盘序列号

在调用前一定要手动在引用中加入System.Management.dll.

 

代码如下:

 ManagementObjectSearcher search = new ManagementObjectSearcher("Select * from Win32_PhysicalMedia");
            string strHardDiskID = null;
            foreach (ManagementObject mo in search.Get())
            {
                strHardDiskID = mo["SerialNumber"].ToString().Trim();
                break;
            }
            this.Text = strHardDiskID;

 

posted on 2012-12-18 17:08  天上星  阅读(170)  评论(0编辑  收藏  举报

导航