Winreg

Barry barry at barrys-emacs.org
Wed Jul 29 17:12:52 EDT 2020



> On 29 Jul 2020, at 19:50, R Pasco <pascor22234 at gmail.com> wrote:
> 
> I'm running python 3.8 on Windows 8.1 x64. Running the following code
> produces no errors but does not add a key, name or value. I had no problems
> doing this using _wirreg under python 2.7. Any insight will be helpful.

How do you check that the key is present?

Are you aware that there is one registry for 32 bit code and a separate registry for 64 bit code.

if you run a 32 bit program to write the registry it will not be seen by 64 bit code for example.

Barry

> 
> Code:
> ===================
> import winreg
> 
> hive = winreg.HKEY_LOCAL_MACHINE
> keypath = 'SOFTWARE\\AAA_Newkey'
> host = None
> hosthive = winreg.ConnectRegistry( host, hive )
> key = winreg.CreateKeyEx( hosthive, keypath, reserved=0,
> access=winreg.KEY_WRITE)
> winreg.SetValueEx( key, 'NewValueName', 0, winreg.REG_SZ, 'NewStringValue' )
> key.Close()
> ===================
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list