C#编写的用光盘做启动盘全程描述
C#编写的用光盘做启动盘全程描述 |
《世界商业评论》ICXO.COM ( 日期:2004-08-26 11:24) |
|
C#编写的用光盘做启动盘全程描述 using System; namespace AT_RegCDRom /// Form1 的摘要说明。 /// public class Form1 : System.Windows.Forms.Form { /// /// 必需的设计器变量。 /// private System.ComponentModel.Container components = null; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button button1; private static string cdRomSn; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // /// /// 清理所有正在使用的资源。 /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); this.label1 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 // this.label1.Location = new System.Drawing.Point(72, 16); this.label1.Name = label1; this.label1.Size = new System.Drawing.Size(144, 24); this.label1.TabIndex = 0; this.label1.Text = 点击开始进行光盘注册; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // button1 // this.button1.Location = new System.Drawing.Point(104, 56); this.button1.Name = button1; this.button1.Size = new System.Drawing.Size(72, 24); this.button1.TabIndex = 1; this.button1.Text = 开始注册; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(280, 101); this.Controls.Add(this.button1); this.Controls.Add(this.label1); this.Icon = ((System.Drawing.Icon)(resources.GetObject($this.Icon))); this.MaximizeBox = false; this.Name = Form1; this.Text = 光盘注册; this.ResumeLayout(false); } /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.Run(new Form1()); } /// /// 读取光盘相关信息并进行注册。 /// public void ReadCDRom() { //创建获取光盘信息对象 ManagementClass driveClass = new ManagementClass(Win32_CDROMDrive); //返回该类的所有实例的集合 status=false; } string message = 请插入要注册的启动光盘!; // Displays the MessageBox. result = MessageBox.Show(this, message, caption, buttons, /// 把信息写入注册表。 /// public bool RegCDRomSn(string sn) { try { // 在HKEY_LOCAL_MACHINESoftware下建立一新键,起名为CDDriveSn RegistryKey key = Registry.LocalMachine.OpenSubKey(Software, true); // 增加一个子键 RegistryKey newkey = key.CreateSubKey(CDDriveSn); // 设置此子键的值 newkey.SetValue(CDDriveSn, sn); // 成功返回true return true; } } private void button1_Click(object sender, System.EventArgs e) } 2、验证[应用] |