简体   繁体   中英

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.

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. 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 .

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. This answer has more detail: 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM