从32位Python更改64位注册表 [英] Change 64bit Registry from 32bit Python
问题描述
我很难理解这一点。如果我是对的,则32位Python无法运行代码并以64位更改注册表值。我说对了吗?还是有启用此功能的开关?
I am having difficulty do understand this. If I'm correct, A 32bit Python can't run a code and change registry values in 64bit. Do I get it right? Or is there a switch to turn on in which enables this functionality?
有以下内容:
http://msdn.microsoft.com/en-us/library/aa384129%28v=VS.85% 29.aspx
但是如何在以下代码中使用它?
http:// www.blog.pythonlibrary.org/2010/03/20/pythons-_winreg-editing-the-windows-registry/
But how do I use it with the following code? http://www.blog.pythonlibrary.org/2010/03/20/pythons-_winreg-editing-the-windows-registry/
感谢,
Oz
Thanks, Oz
推荐答案
正如您链接的MSDN文章所述,64位Windows具有两个注册表视图,一个用于32位,另一个用于64位。默认情况下,32位应用程序(例如,您的Python脚本由32位Python解释器执行)将访问32位视图。您可以使用MSDN文章中提到的标志来强制其访问64位视图。为了能够使用这些标志,您需要调用 _winreg.OpenKey
, _winreg.CreateKeyEx
或 _winreg.DeleteKeyEx
具有正确的参数,例如
As the MSDN article you linked to explains, 64bit Windows has two registry views, one for 32bit and one for 64bit. By default a 32bit application (e.g. your Python script being executed by a 32bit Python interpreter) will access the 32bit view. You can force it to access the 64bit view using the flags mentioned in the MSDN article. To be able to use these flags you need to call _winreg.OpenKey
, _winreg.CreateKeyEx
or _winreg.DeleteKeyEx
with the correct parameters, e.g.
handle = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "your_sub_key", 0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
请参见 _winreg
文档以获取更多信息。
See the _winreg
documentation for more information.
这篇关于从32位Python更改64位注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!