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

标签 python windows registry 64-bit

我的程序正在尝试创建一个 key

HKLM\Software\Microsoft\Shared Tools\MSCONFIG\startupreg\test\

而是在上创建 key

HKLM\Wow6432node\Software\Microsoft\Shared Tools\MSCONFIG\startupreg\test\

并且无法正常工作...为什么?怎么解决呢?

最佳答案

有关 winreg 中的反射关键功能的文档很少(并且缺少一些零散的内容)。您确实需要this patch ,但在应用它并使用这些修复程序制作新的 Python 微版本之前,至少您可以根据补丁添加的文档尝试 DisableReflectionKey 等路由(这是它们的 RST):

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

关于python - 如何在 Python 上关闭注册表重定向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2404595/

相关文章:

python - 使用 google-api-python-client init() 方法时出现 SSL 错误

c# TrimEnd 删除超过需要的?

c++ - 如何在 Windows 启动时启动应用程序?

windows - 可能使用提升的权限创建的日志文件

python - 如何捕获线程中发生的异常?

c++ - 嵌入式 Python 值冲突

php - 在 Windows 上为 PHP 和 Apache 安装 Imagick

Windows 模拟 token 过期时间

c++ - 在带有 mingw 的 Windows 上使用 openmp。找不到 -lpthread

python - Django 对象 ID 在单元测试之间递增