Read access to the registry RRS feed

  • Question

  • Hi,

    Does ClickOnce app have read-only access to HKLM registry key? I have full-trust clickOnce app but


    returns null.

    I tried other input params for OpenSubKey method but it always returns null.

    This same code returns the key when app is ran as desktop app(not ClickOnce) on the same machine.

    Am I doing smthg wrong or ClickOnce app does not have read access to registry?


    Wednesday, January 4, 2012 4:35 PM


All replies

  • Those items should be readable - run regedit and look at permissions. 

    You might be getting null because the key doesn't exist, and that might be happening because you're on a 64-bit system and there is a 32-bit registry AND a native 64-bit registry. If your app is AnyCpu it will look in the native registry because it will run native 64-bit.

    Phil Wilson
    • Proposed as answer by REHAN BHARUCHA Thursday, January 5, 2012 12:44 PM
    • Marked as answer by Bob Wu-MT Friday, January 20, 2012 4:57 AM
    Wednesday, January 4, 2012 6:40 PM
  • Wow, you're right. Desktop app was running as x64 bit process and was finding the key, while ClickOnce was running in 32bit IE as 32bit process and wasn't finding it! I switched to 64 bit IE and it worked.

    I didn't realize that registry keys could be "bitness" specific.

    Well, now the question is - what do I do about it?

    I installed Oracle client on 64bit machine, which obviously created 64bit registry keys, but didn't create 32bit keys.

    My ClickOnce app can be ran in 32bit IE or 64bit IE. So now for 32bit IE users it won't work.

    Can you suggest any solution?



    Wednesday, January 4, 2012 7:45 PM
  •  Hi Isolda,
    You can read 64bit Registry from a 32bit application by using RegOpenKeyEx function (http://msdn.microsoft.com/en-us/library/ms724897.aspx ). KEY_WOW64_64KEY flag enable access a 64-bit key from either a 32-bit or 64-bit application (http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx ).
    The following link provides a way to use RegOpenKeyEx function.
    If there is anything unclear, please let me know.
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us
    • Marked as answer by Bob Wu-MT Friday, January 20, 2012 4:57 AM
    Monday, January 9, 2012 10:09 AM