日期:2014-05-18  浏览次数:20713 次

求解……一段托盘图标代码,路过都来看看
string startup = Application.ExecutablePath;
  RegistryKey rKey = Registry.LocalMachine;  
  RegistryKey autoRun = rKey.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
  autoRun.SetValue("BookServer", startup); 
  rKey.Close();

------解决方案--------------------
C# code

   //设置要开机启动的文件路径
            string startup = Application.ExecutablePath;
            //建立注册表的键值
            RegistryKey rKey = Registry.LocalMachine;
            //创建注册表的键
            RegistryKey autoRun = rKey.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
            //设置键值,第一个参数是名称,第二个参数是路径
            autoRun.SetValue("BookServer", startup);
            rKey.Close();