RegistryKey rkStartUp = Registry.CurrentUser;
RegistryKey StartupPath;
StartupPath =rkStartUp.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (StartupPath.GetValue("MyApplication") == null)
{
StartupPath.SetValue("MyApplication", Application.ExecutablePath, RegistryValueKind.ExpandString);
}
else
{
StartupPath.DeleteValue("MyApplication", true);
}
RegistryKey rkStartUp = Registry.CurrentUser; RegistryKey StartupPath; StartupPath =rkStartUp.OpenSubKey(@Software\Microsoft\Windows\CurrentVersion\Run, true); if (StartupPath.GetValue(MyApplication) == null) {
Share
First of all, be aware that registry keys are different for 32-bit and 64-bit systems. Also, in case your application is not running with admin rights, it is probably not permitted to write registry keys.