Access Wine registry from python

Questions about Wine on Linux
Locked
johnmcd
Newbie
Newbie
Posts: 2
Joined: Thu Oct 28, 2021 12:22 pm

Access Wine registry from python

Post by johnmcd »

Hi all,

I'm just getting started with wine and I had a quick question - how can I access Wine' registry from a python program? Will winreg work, or do I have to use something else?

Thanks

John
jkfloris
Level 12
Level 12
Posts: 3201
Joined: Thu Aug 14, 2014 10:10 am

Re: Access Wine registry from python

Post by jkfloris »

I did a simple test and it seems to work.
- Install python 3.10 in Wine 6.20
- Create a python file (C:\WinREG.py):

Code: Select all

import winreg
#connecting to key in registry
access_registry = winreg.ConnectRegistry(None,winreg.HKEY_LOCAL_MACHINE)

access_key = winreg.OpenKey(access_registry,r"SOFTWARE\Microsoft\Windows\CurrentVersion")
#accessing the key to open the registry directories under
for n in range(20):
   try:
      x =winreg.EnumKey(access_key,n)
      print(x)
   except:
      break
- Run: python C:\WinREG.py in cmd

Code: Select all

python C:\WinREG.py
App Paths
Control Panel
Controls Folder
Explorer
Fonts
Group Policy
Installer
Internet Settings
Policies
PreviewHandlers
Run
RunOnce
RunServices
RunServicesOnce
Setup
Shell Extensions
Telephony
Time Zones
Uninstall
URL
johnmcd
Newbie
Newbie
Posts: 2
Joined: Thu Oct 28, 2021 12:22 pm

Re: Access Wine registry from python

Post by johnmcd »

Perfect - thank you!
Locked