Click here to Skip to main content
15,881,092 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to manually create keys under HKEY_CLASSES_ROOT\CLSID. If the key does not start with {, I can create the key successfully. If I attempt to create a key with a starting left bracket, IE "{68FAB877-EAF8-3196-9360-1AADDCDABE1B}", no error is returned but the key isn't created either.

VB
'regkey is set to HKEY_CLASSES_ROOT
regKey.CreateSubKey(CheckRegKey(vNewSubKey)).Close()


If I use the same code and pass in ".{68FAB877-EAF8-3196-9360-1AADDCDABE1B}", the key is created. I can then go into regedit and manually rename the key taking out the period and everything is peachy. Given that I can create any other key, I'm confident that the createsubkey line is valid.

How can I create the key correctly through code so that it includes the left bracket?

André:
After reading your post, I did some testing. I broke out my code that is used above to this:
VB
MsgBox("creating Key")
RegKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Classes\CLSID\", True)
RegKey.CreateSubKey("{00000000-EAF8-3196-9360-1AADDCDABE1B}")
RegKey.Close()


I tested the above code on my box (WinXP x64) and it doesn't create the necessary key.
I tested the code on a WinXP (32 bit box) and it works fine.
I tested on another box that is Win7, x86 and it was fine.

Tried on another box that is Win7 x64 and it doesn't work again. So it appears the issue is with writing the key on x64 boxes. Any ideas?
Posted
Updated 26-Oct-11 3:59am
v2
Comments
André Kraak 25-Oct-11 15:04pm    
I just check it using C# and I am able to create the key.

Perhaps you can post the code for how you open the regKey and the implementation of the CheckRegKey function as it does not seem to be a standard function.

If you wish to change your question use the Improve Question button.

1 solution

hi,

try recompiling you app with "AnyCpu"
you could have compiled it for X86 alone

you can check this link, it might be f help
http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/92f962d6-7f5e-4e62-ac0a-b8b0c9f552a3
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900