Go to my modified registry, but the program runs up, or remember the previous

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.