如何在Python中访问HKEY_CLASSES_ROOT

时间:2014-10-31 19:09:04

标签: python

我正试图在root下添加一个注册表项,如此

 reg = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, "jpegfile", 0, _winreg.KEY_SET_VALUE)

但我收到了这个错误

E:\hello.py
Traceback (most recent call last):
File "E:\hello.py", line 22, in <module>
define_action_on(".jpeg", "Upload", "\"E:\\python\\python.exe\" \"E:\\hello.
py\" \"%1\"", title="Upload to imgur with python")
File "E:\hello.py", line 16, in define_action_on
reg = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, "jpegfile", 0, _winreg.KEY_
SET_VALUE)
WindowsError: [Error 5] Access is denied

1 个答案:

答案 0 :(得分:0)

以管理员身份运行您的代码。