
Regtype = regtype or QueryValueEx(key, name) With OpenKey(root, path, 0, KEY_WRITE|KEY_READ) as key: def write(path, value, root=HKEY_CURRENT_USER, regtype=None): Provide type as argument, match current type in registry or python value type. With OpenKey(root, path, 0, KEY_WRITE) as key:Įxtended for type handling. With suppress(FileNotFoundError), OpenKey(root, path) as key:Īnd writing: def write(path, value, root=HKEY_CURRENT_USER): Reading registry keys: def read(path, root=HKEY_CURRENT_USER): #*For instant apply of SystemParameters like the mouse speed on-write, you can use win32gui/SPI #Set Value 1/20 (will just write the value to reg, the changed mouse val requires a win re-log to apply*) Value, regtype = winreg.QueryValueEx(registry_key, name) Winreg.SetValueEx(registry_key, name, 0, winreg.REG_SZ, value) Registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, REG_PATH, 0, Winreg.CreateKey(winreg.HKEY_CURRENT_USER, REG_PATH) I get a error like below: Traceback (most recent call last):įile "D:\PROJECT\project.py", line 305, in OnOkĪnd to read from registry,the saved registry has to show up in the setting window.I tried with the below code.Though its working but not satisfied with the way i programmed it.Help me out for the better solution key = OpenKey(HKEY_CURRENT_USER, r'Software\my path to\Registry', 0, KEY_READ)

SetValueEx(keyVal,"Log file",0,REG_SZ,data1) KeyVal=OpenKey(aReg,r"SOFTWARE\my path to\Registry", 0,KEY_WRITE)

def OnOk(self, event):ĭata1=() #path selected in setting windowĪReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) I have developed a python script where i have a setting window which has the options to select the paths for the installation of software.When clicked on OK button of the setting window, i want to write all the selected paths to the registry and read the same when setting window is opened again.
