如何在HKEY_CLASSES_ROOT \ CLSID下创建GUID键 [英] How to create a guid key under HKEY_CLASSES_ROOT\CLSID

查看:256
本文介绍了如何在HKEY_CLASSES_ROOT \ CLSID下创建GUID键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在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?

推荐答案



尝试使用"AnyCpu"重新编译您的应用程序
您本可以仅针对X86进行编译

您可以检查此链接,可能对您有帮助
http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/92f962d6-7f5e-4e62-ac0a-b8b0c9f552a3


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


这篇关于如何在HKEY_CLASSES_ROOT \ CLSID下创建GUID键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆