ScubaSteve7
Member
- Joined
- Dec 1, 2010
- Sythe Gold
- 0
- Messages
- 35
So this is my attempt at writing to the registry for my program to open up when windows starts.
When trying to write the executable path to the registry, I get his error:
Any ideas as to what I'm doing wrong? I'm a newb.
Code:
RegistryKey App = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsft\\Windows\\CurrentVersion\\Run", true);
if (App.GetValue("MyApp") == null)
{
App.DeleteValue("MyApp", false);
App.SetValue("MyApp", System.Reflection.Assembly.GetExecutingAssembly().Location.ToString());
Console.WriteLine("Program runs at startup.");
}
else
Console.WriteLine("Program runs at startup.");
When trying to write the executable path to the registry, I get his error:
Code:
System.NullReferenceException: Object reference not set to an instance of an object.
at App.Program.Main(String[] args) in C:\Users\Steve\Desktop\csLK\csLK\
Program.cs:line 41
Any ideas as to what I'm doing wrong? I'm a newb.















