PDA

View Full Version : Copying registry key..



sazukaru
06-22-2001, 05:48 PM
Hi,

I need to copy an entire key from HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER.

How can I do that? I am using Delphi 5.

Thanks.

RWSchlatter
06-25-2001, 10:01 PM
Sorry J cannot tell you where to look in Delphi5 for what may already be included with the product.
But the Registry API is defined at:
http://msdn.microsoft.com/library/en-us/sysinfo/hh/sysmgmt/regapi_6so5.asp (http://www.winguides.com/external.php?url=http://msdn.microsoft.com/library/en-us/sysinfo/hh/sysmgmt/regapi_6so5.asp)
and if the required functions are not supplied by Delphi, you can write your own wrapper code for them.

Concerning your actual problem, you will have to browse the whole HKLM key tree and copy each subkey and its (optional) data over to HKCU, and same with each value name and its data. There is no API function to copy a whole tree structure.

But maybe you will be just as fast by exporting the key and all its content with Regedit.exe, read the file into an editor and globally change/replace the HKLM name part by HKCU, and then merge the file back into the registry.

______________
Regards - Richard