[英]How can I programmaticaly create registry key in HKEY_CLASSES_ROOT in \CLSD\{XXXXXXXXX,xxxxxxxx,XXXXX,xxxxx} delphi xe2?
I tried to create regisrty key in HKEY_CLASSES_ROOT but windows doesn't allow to do this , I'm trying to create it in HKEY_CURRENT_USER \\SOFTWARE\\Classes\\CLSID{xxxxxx-xxxxxxx-xxxxxxx-xxxxxx}\\abc , but it didn't created. 我试图在HKEY_CLASSES_ROOT中创建注册密钥,但Windows不允许这样做,我试图在HKEY_CURRENT_USER \\ SOFTWARE \\ Classes \\ CLSID {xxxxxx-xxxxxxx-xxxxxxx-xxxxxx} \\ abc中创建它,但是没有创建。
this is my code, whers my fault and how i can solve it. 这是我的代码,提醒我我的错误以及如何解决。
procedure TForm1.FormCreate(Sender: TObject);
const
RegKey = '\Software\Classes\CLSID';
var
Reg: TRegistry;
DelphiPath: String;
begin
Reg:= TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
Reg.CreateKey('SOFTWARE\Classes\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\abc');
Reg.Free;
end;
The key will have been created. 密钥将被创建。 That you did not report an exception means that the code executed sucessfully. 没有报告异常意味着代码已成功执行。 But HKCU\\Software\\Classes\\CLSID
is a redirected key. 但是HKCU\\Software\\Classes\\CLSID
是重定向的密钥。 You have a 32 bit process and the registry redirector will have created the key in the 32 bit view, that is HKCU\\Software\\Classes\\Wow6432Node\\CLSID
. 您有一个32位进程, 注册表重定向器将在32位视图中创建密钥,即HKCU\\Software\\Classes\\Wow6432Node\\CLSID
。
If you need to create the key in the 64 bit view you can include the KEY_WOW64_64KEY
flag in the Access
property of the registry object. 如果需要在64位视图中创建密钥,则可以在注册表对象的Access
属性中包含KEY_WOW64_64KEY
标志。 This answer has more detail: https://stackoverflow.com/a/9126382/505088 该答案有更多详细信息: https : //stackoverflow.com/a/9126382/505088
However, if your COM server is a 32 bit server, then you should let the redirector do its work. 但是,如果您的COM服务器是32位服务器,则应让重定向器执行其工作。
If all of the above makes no sense to you because you've never heard of the registry redirector then you need to follow the link in the first paragraph before proceeding. 如果以上所有内容对您没有意义,因为您从未听说过注册表重定向器,那么您需要先阅读第一段中的链接,然后再继续。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.