使用 regedit.exe 我在注册表中手动创建了一个名为
HKEY_CURRENT_USER/00_Just_a_Test_Key的键
并创建了两个 dword 值
dword_test_1 和 dword_test_2
我正在尝试使用以下程序将一些值写入这两个键
import _winreg
aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_CURRENT_USER)
aKey = _winreg.OpenKey(aReg, r"00_Just_a_Test_Key", 0, _winreg.KEY_WRITE)
_winreg.SetValueEx(aKey,"dword_test_1",0, _winreg.REG_DWORD, 0x0edcba98)
_winreg.SetValueEx(aKey,"dword_test_2",0, _winreg.REG_DWORD, 0xfedcba98)
_winreg.CloseKey(aKey)
_winreg.CloseKey(aReg)
我可以写入第一个键 dword_test_1,但是当我尝试写入第二个键时,我收到以下消息
Traceback (most recent call last):
File "D:/src/registry/question.py", line 7, in <module>
_winreg.SetValueEx(aKey,"dword_test_2",0, _winreg.REG_DWORD, 0xfedcba98)
ValueError: Could not convert the data to the specified type.
如何将第二个值 0xfedcba98 或任何大于 0x7fffffff
的值写入 dword 值?
最初我正在编写脚本来打开或关闭“我的文档”图标,方法是编写“0xf0500174”来隐藏或“0xf0400174”来显示图标到 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID{450D8FBA-AD25 -11D0-98A8-0800361B1103}\ShellFolder]