[RESOLVED] My program creates invisible registry keys...
My program runs this code to add an autostart key to the registry:
Code:
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "MyAppName", "" + Application.ExecutablePath + "");
The problem here is that I can't see the key it has created in regedit.
If I run some code to get the value of the key in my program, it returns a correct value. Meaning that the program can read the key but I can't.
Wt*? :ehh:
I am admin btw and have UAC off.
EDIT: Another question too: Why can I set a value with the above code but I receive an unauthorizedexception when doing it with the OpenSubKey thingy?
Re: My program creates invisible registry keys...
Have you any anti-virus program turned on that prevents wirtes to the registry. If so, disable your anti-virus and see if that helps.
Re: My program creates invisible registry keys...
If you have a 64bit Windows version the reg-key might be:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6232Node\Microsoft\Windows\CurrentVersion\Run
Re: My program creates invisible registry keys...
That was it :)
Weird that it created the key there when I told it not to :P
Re: My program creates invisible registry keys...
Off topic but, what's the point of concatenating empty string literals?
Quote:
Code:
"" + Application.ExecutablePath + ""
Re: My program creates invisible registry keys...
Woah typing error, It should be Chr(36), or """" of course :)
Re: My program creates invisible registry keys...
Quote:
Originally Posted by
Cyb3rH4Xter
Woah typing error, It should be Chr(36), or """" of course :)
That would be for VB. In C# you could do this:or this:but I'd sooner use String.Format in both languages:
Code:
string.Format("\"{0}\"", str)
It's no more correct but, to me, it's clearer.
Re: [RESOLVED] My program creates invisible registry keys...
Of course....I can use the backslash :P thx for the tips :-)