zoukankan      html  css  js  c++  java
  • 关于取硬盘序列号

    测试环境:win7 64位

     参考:http://www.cnblogs.com/lenmom/p/8556611.html

    方法1,结果:5VP9MZ60

     ManagementClass mc = new ManagementClass("Win32_PhysicalMedia");
                //网上有提到,用Win32_DiskDrive,但是用Win32_DiskDrive获得的硬盘信息中并不包含SerialNumber属性。   
                ManagementObjectCollection moc = mc.GetInstances();
                string strID = null;
                foreach (ManagementObject mo in moc)
                {
                    strID = mo.Properties["SerialNumber"].Value.ToString();
                    break;
                }
                textBox1.Text += "硬盘 ID:" + strID;

    方法2,结果:4031371149,同方法3,此是10进制。

     ManagementObjectSearcher mos = new ManagementObjectSearcher();
                mos.Query = new SelectQuery("Win32_DiskDrive", "", new string[] { "PNPDeviceID", "Signature" });
                ManagementObjectCollection myCollection = mos.Get();
                ManagementObjectCollection.ManagementObjectEnumerator em = myCollection.GetEnumerator();
                em.MoveNext();
                ManagementBaseObject moo = em.Current;
                string id = moo.Properties["Signature"].Value.ToString().Trim();
                this.textBox1.Text = id;

    方法3,结果:F049D78D,同方法2,一个是10进制,一个是16进制

    CMD指令:diskpart,具体操作方法百度查。

    方法4,结果:5VP9MZ60

    使用软件:Everest.exe

    四种方法,共有两个结果,哪个是对的呢?

    其实网上除了c#托管代码读硬盘号外,还有一些win32做好的dll,测试下来也是5VP9MZ60,甚至有人说普通权限运行和管理员权限运行得到的结果也不一样。

    最终还是把电脑打开自己看,结果显示,S/N: 5VP9MZ60,有图有真像。

  • 相关阅读:
    array_merge
    漏斗模型
    3 破解密码,xshell连接
    2-安装linux7
    1-Linux运维人员要求
    17-[模块]-time&datetime
    16-[模块]-导入方式
    Nginx服务器
    15-作业:员工信息表查询
    14-本章总结
  • 原文地址:https://www.cnblogs.com/81/p/9763311.html
Copyright © 2011-2022 走看看