Transferred from: http://www.csframework.com/archive/2/arc-2-20121231-1969.htm
/// <summary> ///Windows Startup Project Management/// </summary> Public classwinstartitems{Const stringReg_path =@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; /// <summary> ///Pick up the program installation location/// </summary> /// <param name= "Registname" >Key Name</param> /// <returns></returns> Public Static stringGetregistdata (stringregistname) { stringRegistdata; RegistryKey Key= Registry.LocalMachine.OpenSubKey (Reg_path,true); Registdata=convertex.tostring (key. GetValue (Registname)); returnRegistdata; } /// <summary> ///Name of the startup project that takes the registry startup entry/// </summary> /// <returns></returns> Public Static string[] Getregistname () {RegistryKey key= Registry.LocalMachine.OpenSubKey (Reg_path,true); returnkey. GetValueNames (); } /// <summary> ///writes the program's boot start to the registry/// </summary> /// <param name= "Runname" >Startup Project Name</param> /// <param name= "Staruppath" >program file name</param> /// <returns></returns> Public Static BOOLRegiststartitem (stringRunname,stringStaruppath) { Try{RegistryKey key= Registry.LocalMachine.OpenSubKey (Reg_path,true); Key. SetValue (Runname, Staruppath); return true; } Catch { return false; } } }
"Go" C # setting up Windows Startup items