zoukankan      html  css  js  c++  java
  • 恢复注册表

    实现效果:

      

    知识运用:

      Process类的StartInfo  StandardInput属性及Start方法

    实现代码:

            public Form2()
            {
                InitializeComponent();
                button1.Click-=new EventHandler(button1_Click);     //取消父类的单击事件
                button2.Click -= new EventHandler(button2_Click);   //取消父类的单机事件
            }
            private void button1_Click_1(object sender, EventArgs e)
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Filter = "*.reg|*.reg";
                if (open.ShowDialog() == DialogResult.OK)
                    textBox1.Text = open.FileName;
            }
            private void button2_Click_1(object sender, EventArgs e)
            {
                try
                {
                    Process myProcess = new Process();
                    myProcess.StartInfo.FileName = "cmd.exe";
                    myProcess.StartInfo.UseShellExecute = false;
                    myProcess.StartInfo.CreateNoWindow = true;
                    myProcess.StartInfo.RedirectStandardError = true;
                    myProcess.StartInfo.RedirectStandardInput = true;
                    myProcess.StartInfo.RedirectStandardOutput = true;
                    myProcess.Start();
                    myProcess.StandardInput.WriteLine("regedit /s " + textBox1.Text);
                    MessageBox.Show("注册表恢复成功");
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message); }
            }
    

      

  • 相关阅读:
    暑假学习
    暑假学习
    暑假学习
    暑假学习
    暑假学习
    经验教训+总结
    NT 时刻
    联赛模拟测试 17
    联赛模拟测试 16
    联赛模拟测试 15
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10326778.html
Copyright © 2011-2022 走看看