Results 1 to 8 of 8

Thread: [RESOLVED] My program creates invisible registry keys...

  1. #1

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Resolved [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*?

    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?
    Last edited by Cyb3rH4Xter; Apr 24th, 2011 at 12:58 PM.

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    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.

  3. #3
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611

    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
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  4. #4

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: My program creates invisible registry keys...

    That was it
    Weird that it created the key there when I told it not to :P

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: My program creates invisible registry keys...

    Off topic but, what's the point of concatenating empty string literals?
    Code:
    "" + Application.ExecutablePath + ""
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: My program creates invisible registry keys...

    Woah typing error, It should be Chr(36), or """" of course

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: My program creates invisible registry keys...

    Quote Originally Posted by Cyb3rH4Xter View Post
    Woah typing error, It should be Chr(36), or """" of course
    That would be for VB. In C# you could do this:
    Code:
    '"' + str + '"'
    or this:
    Code:
    "\"" + str + "\""
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: [RESOLVED] My program creates invisible registry keys...

    Of course....I can use the backslash :P thx for the tips :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width