开发者

Access to local machine in windows 7

开发者 https://www.devze.com 2023-01-03 14:31 出处:网络
I want to create a registry key in local machine hive in windows 7. I used the following code in order to do so:

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.ReadWriteSubTr开发者_Go百科ee);

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


Are you on a 64 bit machine?

If you are on a 64 bit machine, check your project Build settings (Project Properties > Build tab) and check the Platform target.

If the Platform target is set to x86, and you are on a 64 bit machine the key will be created under the 'Wow6432Node'

In regedit.exe look in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node and you should see your key there.

Change the Platform target to Any CPU and it will create the key in HKEY_LOCAL_MACHINE\SOFTWARE


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消