我还不太懂注册表,所以最好能够把代码写的详细一些 ,谢谢了

解决方案 »

  1.   

    using Microsoft.Win32;
    //添加注册表
    RegistryKey hklm=Registry.LocalMachine;
    RegistryKey run=hklm.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");

    try
    {
    run.SetValue(名称,要运行程序的路径);
    MessageBox.Show("   注册表添加成功!!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information );
    hklm.Close();
    button1_Click(this.button2,null);
    } catch(Exception my)
    {
    MessageBox.Show(my.Message.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error );
    }
      

  2.   

    Application.ExecutablePath 获得路径和文件名
      

  3.   

    通過 dazhu2(边城浪子【倚天不出,谁与争锋】)
    給的代碼,你也可以把任何可執行的文件加入註冊表來運行.
    如 你想把D盤下面的tractor.exe加入
    只要
    run.SetValue("tractor.exe","D:\\tractor.exe");
    就OK了,為了通用你還可以把名称,要运行程序的路径作為參數來配置之個
    運行這個程序.