I modified the registry, but the program runs up, or remember the previous one,
I looked at the relevant information, said the changes are only temporarily saved in memory, and did not save to harddisk, please expert guidance, I wrote in Python, the code is as follows
Import Win32API
Import Win32con
def regsubkeyset (DbName, dbversion):
Key = Win32API. RegOpenKey (Win32con. HKEY_CURRENT_USER, ' Software\\dsa\\prodis office\\settings ', 0,win32con. key_all_access)
Win32API. RegQueryValueEx (Key, ' Data Source ')
Win32API. RegSetValueEx (Key, ' Data Source ', 0,win32con. Reg_sz,dbname)
Win32API. RegSetValueEx (Key, ' expversion ', 0,win32con. Reg_sz,dbversion)
Win32API. RegCloseKey (Key)
# Test------------------------------------------------------------------
if __name__ = = "__main__":
Pass
Try it with _winreg.
That's what I was using.
Related examples:
Registry settings:
Build key
>>> Import _winreg
>>> root = _winreg. HKEY_Local_Machine
>>> Proxy_path = r "Software\py"
>>> hkey = _winreg. CreateKey (Root,proxy_path) #注册表里如果已经存在proxy_path则建一个, open if available
>>> _winreg. SetValueEx (hkey, "py", 0,_winreg. REG_SZ, "PY is the best.") #新建一个字符串值
Registration table:
Name Type data
Py REG_SZ py is the best.
Read the information for key that already exists in the registration table:
>>> x = _winreg. Connectregistry (None, _winreg. HKEY_LOCAL_MACHINE)
>>> y = _winreg. Openkey (x,r "Software\py")
>>> value = _winreg. QueryValueEx (y, ' py ') [0] #如果没有
>>> Print Value
PY is the best.
Find out if a key exists:
>>> hkey = _winreg. Openkey (_winreg. Hkey_local_machine,r "Software\py")
>>> KeyInfo = _winreg. Queryinfokey (HKEY)
>>> Keyinfo[1]
1
>>> _winreg. Enumvalue (hkey,0)
(' Install_dir ', U ' d:\\py ', 1)
>>> N,v,t = _
>>> N
' Install_dir '
>>> n = = ' Install_dir '
False
>>> n = = ' Install_dir '
True
>>> V
U ' d:\\py '
I hope I can help you.
Go to my modified registry, but the program runs up, or remember the previous