读取CPU序列号 跟 读取硬盘序列号的源码。

解决方案 »

  1.   

    CPU序列号是老黄历啦。只有 Intel Pentium III 才有序列号,而且 0.13um 工艺的 Intel Pentium III 900~1.3GHz 上就已经取消了。
      

  2.   

    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xqf222/archive/2010/02/21/5315144.aspxusing System.Collections.Generic;
    using System.Text;using System.Runtime.InteropServices;
    using System.Reflection;using System.Security;
    using System.Security.Cryptography;
    using System.IO;namespace Common
    {
        public class ComputerInfo
        {
            [DllImport("DiskID32.dll")]
            public static extern long DiskID32(ref byte DiskModel, ref byte DiskID);        public static string GetDiskID()
            {            byte[] DiskModel = new byte[31];
                byte[] DiskID = new byte[31];
                int i;
                string Model = "";
                string ID = "";            if (DiskID32(ref DiskModel[0], ref DiskID[0]) != 1)
                {                for (i = 0; i < 31; i++)
                    {                                        if (Convert.ToChar(DiskID[i]) != Convert.ToChar(0))
                        {
                            ID = ID + Convert.ToChar(DiskID[i]);
                        }
                    }
                    ID = ID.Trim();
                }
                else
                {
                    Console.WriteLine("获取硬盘序列号出错");
                }
                return ID;
            }}