- 论坛徽章:
- 0
|
我在使用DeleteValue时,它一直出现WindowsError.
- >>> from _winreg import *
- >>> run=OpenKey(HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run')
- >>> DeleteValue(run,'TkBellExe')
- Traceback (most recent call last):
- File "<pyshell#12>", line 1, in -toplevel-
- DeleteValue(run,"TkBellExe")
- WindowsError: (5, '')
复制代码
python的文档是这样描述的:
DeleteValue( key, value)
Removes a named value from a registry key.
key is an already open key, or one of the predefined HKEY_* constants.
value is a string that identifies the value to remove.
我是不是使用DeleteValue哪里用错了?
用CreateKey和DeleteKey是可以正常工作的:
- >>> from _winreg import *
- >>> run=OpenKey(HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run')
- >>>CreateKey(run,'loveeddie')
- <PyHKEY object at 0x00AFD130>
- >>>DeleteKey(run,'loveddie')
复制代码
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run是有TkBellExe这个值的,而且就算改为其他值,也出现同样的错误.
问题出在哪里呢? |
|