我的代码如下,
def set_value():
try:
k = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'SOFTWARE\Steelsoft\pdf2word')
# do things with the key here ...
value, type = winreg.QueryValueEx(k, "times")
ivalue = int(value)
ivalue += 1
winreg.SetValueEx(k, "times", 0, winreg.REG_SZ, str(ivalue))
i = ivalue
except Exception as e:
print(e)
# do things to handle the exception here
# 创建新的键
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, 'SOFTWARE\Steelsoft\pdf2word')
# 给新创建的键添加键值
# winreg.SetValue(key, "times", 0, "1")
winreg.SetValueEx(key, "times", 0, winreg.REG_SZ, "1")
在执行winreg.SetValueEx(k, "times", 0, winreg.REG_SZ, str(ivalue))的时候发生异常。
print(e) 打印异常的内容时[WinError 5] 拒绝访问。
请问如何解决?