views:

55

answers:

2

I’m trying to access a certain bit of the registry however it keeps returning null when i try to open it.

However i know the location is correct because i can navigate to it in reedit.

here’s my line of code for trying to access it.

Microsoft.Win32.RegistryKey RK = Microsoft.Win32.Registry.LocalMachine.OpenSubK("Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData", false);

any one got any ideas?

update

it looks like i am seeing a different version fo the registery, this need to be a 32bit app but it needs to be able to see the 32bit and 64bit version of the registery.

Thank you

A: 

Did you apply permissions to access the registry key via the attribute [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag.RegistryPermission)] or are you running the program as administrator? Here's a detailed look at the Security Permissions as per MSDN, more aptly RegistryPermission

tommieb75
A: 

How is your application being run? In other words, what context does your application run under? Is it being run by double clicking on the .exe or is a setup application firing up the process? Setup applications run under a different context than you would expect.

Alex Dresko
its running as a windows sevice
Jonathan D