Fix: Add another uninstall registry path to search emulators

This commit is contained in:
LmeSzinc 2022-06-26 18:02:14 +08:00
parent d3f3447afe
commit 1b65a919d5

View File

@ -14,6 +14,7 @@ asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
class VirtualBoxEmulator:
UNINSTALL_REG = "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
UNINSTALL_REG_2 = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
def __init__(self, name, root_path, adb_path, vbox_path, vbox_name):
"""
@ -39,7 +40,10 @@ class VirtualBoxEmulator:
Raises:
FileNotFoundError: If emulator not installed.
"""
reg = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, f'{self.UNINSTALL_REG}\\{self.name}', 0)
try:
reg = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, f'{self.UNINSTALL_REG}\\{self.name}', 0)
except FileNotFoundError:
reg = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, f'{self.UNINSTALL_REG_2}\\{self.name}', 0)
res = winreg.QueryValueEx(reg, 'UninstallString')[0]
file = re.search('"(.*?)"', res)