views:

89

answers:

2

I want to create a registry key in local machine hive in windows 7. I used the following code in order to do so:

    RegistryKey regKey = Registry.LocalMachine.CreateSubKey(@"Software\Test", RegistryKeyPermissionCheck.ReadWriteSubTree);

the code runs fine without any error. but when I looked at my registy using regedit.exe I don't see the key that i've just created. can anyone help me please.

regards

A: 

In all likelihood your application is running without a manifest and is writing to the virtualized copy of HKLM. To test my theory, right click your exe and choose Run As Administrator. If it then writes to the correct area, this is what is happening.

If this is the issue, either change your mind about writing to HKLM (users don't like UAC prompts) or put a manifest on the exe that has requireAdministrator so that it will always request elevation and work properly.

Kate Gregory
I have put the manifest with the elevation to my exe. but again i cannot see the key from regedit. the interesting thing is that i my code the key is created and I can use it. but I can't see it from regedit. the exe is excuted as administrator.
Nima Rikhtegar
Have you looked in `HKEY_USERS\<you>_Classes\VirtualStore\Machine\Software\Test` to see if it is being written there?
Kate Gregory
+2  A: 

What is the length of your key name? There is a known bug in regedit that wont let you see keys with names longer than 256 characters.

AOI Karasu

related questions