using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management;


//软件注册模块
namespace Php
{
    public partial class FormReg : Form
    {
        public FormReg()
        {
            InitializeComponent();
        }

        private void FormReg_Load(object sender, EventArgs e)
        {
            byte aa = 0;
            Win32.HDiskInfo h = Win32.GetHddInfoNT(aa);
            textBox1.Text = h.SerialNumber.ToString();
            string a = this.GetHd();
            //MessageBox.Show(a);
            textBox1.Text = a;
        }
        public string GetHd()
        {
            ManagementObjectSearcher wmiSearcher = new ManagementObjectSearcher();

            wmiSearcher.Query = new SelectQuery(
            "Win32_DiskDrive",
            "",
            new string[] { "PNPDeviceID" }
            );
            ManagementObjectCollection myCollection = wmiSearcher.Get();
            ManagementObjectCollection.ManagementObjectEnumerator em =
            myCollection.GetEnumerator();
            em.MoveNext();
            ManagementBaseObject mo = em.Current;
            string id = mo.Properties["PNPDeviceID"].Value.ToString().Trim();
            return id;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Clipboard.SetDataObject(textBox1.Text);
            MessageBox.Show("复制成功!","Tips");
        }
    }
}
