问题描述
我正在尝试在HKEY_CLASSES_ROOT \ CLSID下手动创建密钥.如果密钥不是以{开头,那么我可以成功创建密钥.如果我尝试使用左括号(即"{68FAB877-EAF8-3196-9360-1AADDCDABE1B}")创建密钥,则不会返回任何错误,但也不会创建密钥.
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.
'regkey is set to HKEY_CLASSES_ROOT
regKey.CreateSubKey(CheckRegKey(vNewSubKey)).Close()
如果我使用相同的代码并传递.{68FAB877-EAF8-3196-9360-1AADDCDABE1B}",则会创建密钥.然后,我可以进入regedit并手动重命名密钥,以取出句点,一切都变得如梦如幻.鉴于我可以创建任何其他键,因此我有信心createsubkey行是有效的.
如何通过代码正确创建密钥,使其包含左括号?
安德烈:
阅读您的帖子后,我做了一些测试.我打破了上面使用的代码:
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:
MsgBox("creating Key")
RegKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Classes\CLSID\", True)
RegKey.CreateSubKey("{00000000-EAF8-3196-9360-1AADDCDABE1B}")
RegKey.Close()
我在包装盒(WinXP x64)上测试了上面的代码,但没有创建必要的密钥.
我在WinXP(32位盒)上测试了代码,并且工作正常.
我在另一个装有Win7 x86的盒子上进行了测试,一切都很好.
在另一个Win7 x64盒子上尝试过,它不再起作用.因此看来问题出在将密钥写在x64盒子上.有任何想法吗?
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?
推荐答案
这篇关于如何在HKEY_CLASSES_ROOT \ CLSID下创建GUID键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!