意外的注册表重定向 [英] Unexpected Registry redirection
问题描述
我正在使用.reg
文件将注册表项写入注册表.密钥被视为转至
I am writing keys to the registry using a .reg
file. The keys are deemed to go to
HKEY_LOCAL_MACHINE\SOFTWARE
在我的Windows 7 64位计算机上,这可以正常工作.我可以使用RegOpenKeyEx(..., KEY_READ | KEY_WOW64_64KEY, ...)
读取键.
无论如何,在另一个Windows 7 64位上,它们将移至注册表中反映的32位
on my Windows 7 64 bits machine, this works fine. I can read the keys using RegOpenKeyEx(..., KEY_READ | KEY_WOW64_64KEY, ...)
.
Anyway, on another Windows 7 64 bits, they go to the 32 bits reflected part of the registry
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
反而.在这种情况下,我需要使用RegOpenKeyEx(..., KEY_READ | KEY_WOW64_32KEY, ...)
.
.reg
文件就是这样:
instead. In this case I need to use RegOpenKeyEx(..., KEY_READ | KEY_WOW64_32KEY, ...)
.
The .reg
file simply goes like this:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Company\Product]
"ComputerName"="Computer Name"
我无法弄清楚是什么原因导致类似机器上的不同行为.
任何提示吗?
I cannot figure out what causes the different behaviors on similar machines.
Any hint ?
推荐答案
我认为您可能需要删除KEY_WOW64_64KEY
选择器;请参见此处 [
I think you may need to remove the KEY_WOW64_64KEY
selector; see here[^] for Microsoft''s explanation of these features.
1).REG文件与该符号相对于WOW/64位重定向的位置无关.
2)*处理* .REG文件的应用程序最终将成为决定因素.
3)如果您通过regedit32运行REG文件,它将进入WOW重定向区域.如果通过regedit64(或默认的regedit应用程序)运行它,它将进入正常位置.
4)您*不应*直接对WOW键进行编码.如果您的代码必须知道密钥是否已重定向,那么您就在混合使用32位和64位应用程序,但这种情况很少发生,以至于您最终要做的就是使自己感到困惑. Windows会根据应用程序的位"确定要查找的位置.
1) the .REG file has nothing to do with where the symbol goes with respect to the WOW / 64 bit redirection.
2) the application that *processes* the .REG file will end up being the determining factor.
3) if you ran the REG file through regedit32, it will go into the WOW redirected area. If you ran it through regedit64 (or the default regedit application), it will go into the normal location.
4) You should *not* be coding WOW keys directly. If your code has to know if the key is redirected or not, then you are mixing 32 and 64 bit applications which can happen but it rare enough that all you''ll end up doing is confusing yourself. Windows will figure out where to look based on the "bitness" of your application.
这篇关于意外的注册表重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!