Click here to Skip to main content
15,915,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

Here i Developed one Desktop Application So While Installing the Set Up i want to save the Icon in StartUp Folder.Now iam saving the ICON in Desktop.I dont know how to give path to StartUp Folder.If any Information Please share with me.



Regards,

AnilKumar.D
Posted

1 solution

You need to use the Registry for running a program at startup. You can use the RegistryKey class that's in the System.Win32 namespace. The following code shows how to do this:

C#
RegistryKey rk = Registry.CurrentUser;
RegistryKey StartupPath;
StartupPath = rk.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (StartupPath.GetValue("ProjectName") == null)
{
    StartupPath.SetValue("ProjectName", Application.ExecutablePath, RegistryValueKind.ExpandString);
}


Note: RegistryKey is in the System.Win32 namespace, hence don't forget to import it.

Refer: Running a program at startup[^]
 
Share this answer
 
Comments
Anil Honey 206 13-Jul-12 2:55am    
Where i should use this code it is in my Application
Sandeep Mewara 13-Jul-12 3:18am    
In installer!
Anil Honey 206 13-Jul-12 3:23am    
Can u Explian the way how to write that one

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900