Registry Node Decription in Win64

前端 未结 1 2073
花落未央
花落未央 2020-12-22 07:58

I am having one Delphi XE2 Project to create some node and subnodes in Windows Registry as described below:
\"Applic

相关标签:
1条回答
  • 2020-12-22 08:46

    Why does system32 get mapped to SysWOW64?

    This is a rather obscure corner of the registry. Because your process is a 32 bit process the registry redirector interjects. The documentation states:

    In addition, REG_SZ or REG_EXPAND_SZ keys containing system32 are replaced with syswow64. The string must begin with the path pointing to or under %windir%\system32. The string comparison is not case-sensitive. Environment variables are expanded before matching the path, so all of the following paths are replaced: %windir%\system32, %SystemRoot%\system32, and C:\windows\system32.

    The simplest (and possibly the only) way to get around this is to perform the writing from a 64 bit process and thus escape the clutches of the registry redirector.


    Do I have to call OpenKey() for each different key that I write to?

    Yes.


    Do I have to empty all the subkeys before I can delete a key?

    From the documentation of TRegistry.DeleteKey:

    Call DeleteKey to remove a specified key and its associated data, if any, from the registry. Under Windows 95, if the key has subkeys, the subkeys and any associated data are also removed. Under Windows NT, subkeys must be explicitly deleted by separate calls to DeleteKey.

    The reason for this is that DeleteKey calls RegDeleteKeyEx whose documentation states:

    The subkey to be deleted must not have subkeys. To delete a key and all its subkeys, you need to enumerate the subkeys and delete them individually. To delete keys recursively, use the RegDeleteTree or SHDeleteKey function.

    So, if you are prepared to call Windows API functions directly, you can delete a key and its subkeys in one API call, using either of those aforementioned functions.

    If you need to support XP then use SHDeleteKey which you call like this:

    SHDeleteKey(HKEY_CLASSES_ROOT, PChar(SubKeyName));
    
    0 讨论(0)
提交回复
热议问题