campinglasas.blogg.se

Reg key psd repair kit
Reg key psd repair kit














#REG KEY PSD REPAIR KIT WINDOWS#

strange working module, so, I wrote a class called 'WindowsRegistry' for working with Windows registry and 'winreg' module easier. Raise Exception('Could not restore value') Winreg.SetValueEx(registry_key, name, 0, type, value)įor registry_key, data in self.m_eritems():įor name, backup_data in backup_eritems(): Self.m_backup = (existing_value, type, False) Registry_key = self.get_key(hkey, subkey, winreg.KEY_WRITE, True)Įxisting_value = self.get_reg_value(hkey, subkey, name) Value, _ = winreg.QueryValueEx(registry_key, name)ĭef set_reg_value(self, hkey, subkey, name, type, value): Registry_key = self.get_key(hkey, subkey, winreg.KEY_READ, False) Raise Exception('Registry does not exist and could not be created.')ĭef get_reg_value(self, hkey, subkey, name): Registry_key = winreg.CreateKey(hkey, subkey) Registry_key = winreg.OpenKey(hkey, subkey, 0, access) The class was not tested properly so it may contain some bugs: import _winreg as winregĭef get_key(self, hkey, subkey, access, create_if_doesnt_exist=True): Here is a class I wrote (python 2) which has the ability to restore state when you finish manipulating the registry. The context manager interface for winreg was introduced in python 2.6. NOTE: Use of contextlib.suppress() (available since python 3.4) can be replaced by for older versions. SetValueEx(key, name, 0, regtype or REG_DWORD if isinstance(value, int) else REG_SZ, str(value) if regtype=REG_SZ else value) 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.














Reg key psd repair kit