2022-06-16 14:07:12 +01:00
|
|
|
import ctypes as ct
|
|
|
|
import platform
|
|
|
|
import winreg
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from .error import InstallError
|
|
|
|
|
|
|
|
bits = 64 if ct.sizeof(ct.c_voidp) == 8 else 32
|
|
|
|
|
|
|
|
if platform.system() != "Windows":
|
|
|
|
raise InstallError("Only Windows OS supported")
|
|
|
|
|
|
|
|
|
|
|
|
VM_KEY = "VB:Voicemeeter {17359A74-1236-5467}"
|
|
|
|
REG_KEY = "".join(
|
|
|
|
[
|
|
|
|
"SOFTWARE",
|
|
|
|
("\\WOW6432Node" if bits == 64 else ""),
|
|
|
|
"\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def get_vmpath():
|
|
|
|
with winreg.OpenKey(
|
|
|
|
winreg.HKEY_LOCAL_MACHINE, r"{}".format(REG_KEY + "\\" + VM_KEY)
|
|
|
|
) as vm_key:
|
2023-06-23 01:22:50 +01:00
|
|
|
return winreg.QueryValueEx(vm_key, r"UninstallString")[0]
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
|
2023-06-23 01:22:50 +01:00
|
|
|
try:
|
|
|
|
vm_path = Path(get_vmpath())
|
|
|
|
except FileNotFoundError as e:
|
|
|
|
raise InstallError(f"Unable to fetch DLL path from the registry") from e
|
2022-06-16 14:07:12 +01:00
|
|
|
vm_parent = vm_path.parent
|
|
|
|
|
|
|
|
DLL_NAME = f'VoicemeeterRemote{"64" if bits == 64 else ""}.dll'
|
|
|
|
|
|
|
|
dll_path = vm_parent.joinpath(DLL_NAME)
|
|
|
|
if not dll_path.is_file():
|
2023-06-23 01:22:50 +01:00
|
|
|
raise InstallError(f"Could not find {dll_path}")
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
libc = ct.CDLL(str(dll_path))
|