如何在Python上关闭注册表重定向?

如何在Python上关闭注册表重定向?,python,windows,registry,64-bit,Python,Windows,Registry,64 Bit,我的程序正在尝试在 HKLM\Software\Microsoft\Shared Tools\MSCONFIG\startupreg\test\ 但是,密钥是在 HKLM\Wow6432node\Software\Microsoft\Shared Tools\MSCONFIG\startupreg\test\ 而且不能正常工作。。。为什么?如何解决它?您可以使用: import _winreg _winreg.DisableReflectionKey(_winreg.HKEY_LOCAL_M

我的程序正在尝试在

HKLM\Software\Microsoft\Shared Tools\MSCONFIG\startupreg\test\
但是,密钥是在

HKLM\Wow6432node\Software\Microsoft\Shared Tools\MSCONFIG\startupreg\test\
而且不能正常工作。。。为什么?如何解决它?

您可以使用:

import _winreg
_winreg.DisableReflectionKey(_winreg.HKEY_LOCAL_MACHINE)
# do stuff here
_winreg.EnableReflectionKey(_winreg.HKEY_LOCAL_MACHINE)

但是,这只适用于Python 2.6及更高版本。

winreg中关于反射的关键特性的文档很少(而且缺少一些零碎的东西)。您确实需要,但在应用它并使用这些修复程序发布新的Python微版本之前,您至少可以根据修补程序添加的文档尝试
DisableReflectionKey
etc路径(这是它们的RST):


究竟什么东西不能正常工作?它是如何失败的?你能发布代码的相关部分吗?我需要什么样的参数?它请求oneDisable需要一个键或一个预定义常量。完全没有成功=/。。。尝试了_winreg.DisableReflectionKey(_winreg.HKEY_LOCAL_MACHINE),或者使用了一些打开的密钥常量,但没有发生任何情况
+.. function:: DisableReflectionKey(key)
+   
+   Disables registry reflection for 32-bit processes running on a 64-bit
+   Operating System.
+   
+   *key* is an already open key, or one of the predefined :const:`HKEY_\*`
+   constants.
+   
+   Will generally raise :exc:`NotImplemented` if executed on a 32-bit
+   Operating System.

+   If the key is not on the reflection list, the function succeeds but has no
+   effect. Disabling reflection for a key does not affect reflection of any
+   subkeys.

+
+.. function:: EnableReflectionKey(key)
+
+   Restores registry reflection for the specified disabled key.
+   
+   *key* is an already open key, or one of the predefined :const:`HKEY_\*`
+   constants.
+
+   Will generally raise :exc:`NotImplemented` if executed on a 32-bit
+   Operating System.
+   
+   Restoring reflection for a key does not affect reflection of any subkeys.
+
+
+.. function:: QueryReflectionKey(key)
+
+   Determines the reflection state for the specified key.
+   
+   *key* is an already open key, or one of the predefined :const:`HKEY_\*`
+   constants.
+   
+   Returns ``True`` if reflection is disabled.
+
+   Will generally raise :exc:`NotImplemented` if executed on a 32-bit
+   Operating System.