⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 A programe which can help you to operate the regidit
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.Win32;

namespace REG
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ListBox lb1;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private string dz="";
		private string lj="";
		private string cc="";
		private RegistryKey rk;
		public  static string xming="";
		public  static string zxm="";
		public  static string zxs="";
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.ListBox lb2;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.MenuItem menuItem7;
		private System.Windows.Forms.MenuItem menuItem9;
		private System.Windows.Forms.MenuItem menuItem8;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.lb1 = new System.Windows.Forms.ListBox();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.menuItem7 = new System.Windows.Forms.MenuItem();
			this.menuItem9 = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.lb2 = new System.Windows.Forms.ListBox();
			this.SuspendLayout();
			// 
			// lb1
			// 
			this.lb1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.lb1.HorizontalScrollbar = true;
			this.lb1.ItemHeight = 12;
			this.lb1.Items.AddRange(new object[] {
													 "HKEY_CLASSES_ROOT",
													 "HKEY_CURRENT_USER",
													 "HKEY_LOCAL_MACHINE",
													 "HKEY_USERS",
													 "HKEY_CURRENT_CONFIG"});
			this.lb1.Location = new System.Drawing.Point(0, 8);
			this.lb1.Name = "lb1";
			this.lb1.Size = new System.Drawing.Size(416, 328);
			this.lb1.TabIndex = 0;
			this.lb1.DoubleClick += new System.EventHandler(this.lb1_DoubleClick);
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1,
																					  this.menuItem3,
																					  this.menuItem7,
																					  this.menuItem8});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2,
																					  this.menuItem5});
			this.menuItem1.Text = "添加(&A)";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.Text = "添加项";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 1;
			this.menuItem5.Text = "添加子键";
			this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem4,
																					  this.menuItem6});
			this.menuItem3.Text = "删除(&D)";
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 0;
			this.menuItem4.Text = "删除项";
			this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 1;
			this.menuItem6.Text = "删除子键";
			this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
			// 
			// menuItem7
			// 
			this.menuItem7.Index = 2;
			this.menuItem7.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem9});
			this.menuItem7.Text = "修改(&E)";
			// 
			// menuItem9
			// 
			this.menuItem9.Index = 0;
			this.menuItem9.Text = "修改子键";
			this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 3;
			this.menuItem8.Text = "退出(&X)";
			this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click_1);
			// 
			// lb2
			// 
			this.lb2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.lb2.HorizontalScrollbar = true;
			this.lb2.ItemHeight = 12;
			this.lb2.Location = new System.Drawing.Point(424, 8);
			this.lb2.Name = "lb2";
			this.lb2.Size = new System.Drawing.Size(128, 328);
			this.lb2.TabIndex = 1;
			this.lb2.DoubleClick += new System.EventHandler(this.lb2_DoubleClick);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(552, 335);
			this.Controls.Add(this.lb2);
			this.Controls.Add(this.lb1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.Menu = this.mainMenu1;
			this.Name = "Form1";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "注册表操作";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void lb1_DoubleClick(object sender, System.EventArgs e)
		{
			
			try
			{
			if(lb1.SelectedItem.ToString()=="回到定级目录")
			{
				cc="";
				lj="";
				lb1.Items.Clear();
				lb2.Items.Clear();
				lb1.Items.AddRange(new object[] {
													"HKEY_CLASSES_ROOT",
													"HKEY_CURRENT_USER",
													"HKEY_LOCAL_MACHINE",
													"HKEY_USERS",
													"HKEY_CURRENT_CONFIG"});
			}

			if(lb1.SelectedItem.ToString()=="HKEY_CLASSES_ROOT")
			cc="HKEY_CLASSES_ROOT";
			else if(lb1.SelectedItem.ToString()=="HKEY_CURRENT_USER")
			cc="HKEY_CURRENT_USER";
			else if(lb1.SelectedItem.ToString()=="HKEY_LOCAL_MACHINE")
			cc="HKEY_LOCAL_MACHINE";
			else if(lb1.SelectedItem.ToString()=="HKEY_USERS")
			cc="HKEY_USERS";
			else if(lb1.SelectedItem.ToString()=="HKEY_CURRENT_CONFIG")
			cc="HKEY_CURRENT_CONFIG";

			dz=lb1.SelectedItem.ToString();
				if(cc=="HKEY_CLASSES_ROOT")
				{
					if(lb1.SelectedItem.ToString()==dz)
					{	
						lj+=lb1.SelectedItem.ToString()+"\\";
						if(lb1.SelectedItem.ToString()=="HKEY_CLASSES_ROOT")
						{
							lj="";
						}
						lb1.Items.Clear();
						lb1.Items.Add("回到定级目录");
						lb2.Items.Clear();
						RegistryKey rk;
						rk= Registry.ClassesRoot;
						RegistryKey software=rk.OpenSubKey(lj);
						foreach (string site in software.GetValueNames())
						{ 
							lb2.Items.Add(site);
						}
						foreach (string site in software.GetSubKeyNames())
						{ 
							lb1.Items.Add(site);
						}
					}
				}

				if(cc=="HKEY_CURRENT_USER")
				{
					if(lb1.SelectedItem.ToString()==dz)
					{
						lj+=lb1.SelectedItem.ToString()+"\\";
						if(lb1.SelectedItem.ToString()=="HKEY_CURRENT_USER")
						{
							lj="";
						}
						lb1.Items.Clear();
						lb1.Items.Add("回到定级目录");
						lb2.Items.Clear();
						RegistryKey rk;
						rk= Registry.CurrentUser; 
						RegistryKey software=rk.OpenSubKey(lj);
						foreach (string site in software.GetValueNames())
						{ 
							lb2.Items.Add(site);
						}
						foreach (string site in software.GetSubKeyNames())
						{ 
							lb1.Items.Add(site);
						}
					}
				}

				if(cc=="HKEY_LOCAL_MACHINE")
				{
					if(lb1.SelectedItem.ToString()==dz)
					{
						lj+=lb1.SelectedItem.ToString()+"\\";
						if(lb1.SelectedItem.ToString()=="HKEY_LOCAL_MACHINE")
						{
							lj="";
						}
						lb1.Items.Clear();
						lb1.Items.Add("回到定级目录");
						lb2.Items.Clear();
						RegistryKey rk;
						rk=Registry.LocalMachine; 
						RegistryKey software=rk.OpenSubKey(lj);
						foreach (string site in software.GetValueNames())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -