我想了个办法,不过总觉得不好
用System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup)
得到系统启动的文件夹
然后把文件自身复制到那个文件夹中虽然这样也能实现,但是总感觉不爽
写注册表怎么实现呢?

解决方案 »

  1.   

    注册表健HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrenVersion\Run
      

  2.   

    RegistryKey hklm=Registry.CurrentUser;
    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 );
    }
      

  3.   

    用RegistryKey类,他提供了丰富的操作注册表的方法!!