2022-06-16 14:07:12 +01:00
|
|
|
import ctypes as ct
|
|
|
|
import platform
|
|
|
|
import winreg
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from .error import InstallError
|
|
|
|
|
2024-06-29 03:55:15 +01:00
|
|
|
BITS = 64 if ct.sizeof(ct.c_void_p) == 8 else 32
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
if platform.system() != "Windows":
|
|
|
|
raise InstallError("Only Windows OS supported")
|
|
|
|
|
|
|
|
|
|
|
|
VM_KEY = "VB:Voicemeeter {17359A74-1236-5467}"
|
2023-08-13 14:18:39 +01:00
|
|
|
REG_KEY = "\\".join(
|
|
|
|
filter(
|
|
|
|
None,
|
|
|
|
(
|
|
|
|
"SOFTWARE",
|
2024-06-29 03:55:15 +01:00
|
|
|
"WOW6432Node" if BITS == 64 else "",
|
2023-08-13 14:18:39 +01:00
|
|
|
"Microsoft",
|
|
|
|
"Windows",
|
|
|
|
"CurrentVersion",
|
|
|
|
"Uninstall",
|
|
|
|
),
|
|
|
|
)
|
2022-06-16 14:07:12 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def get_vmpath():
|
|
|
|
with winreg.OpenKey(
|
2023-08-13 14:18:39 +01:00
|
|
|
winreg.HKEY_LOCAL_MACHINE, r"{}".format("\\".join((REG_KEY, VM_KEY)))
|
2022-06-16 14:07:12 +01:00
|
|
|
) as vm_key:
|
2024-06-20 17:01:25 +01:00
|
|
|
return winreg.QueryValueEx(vm_key, r"UninstallString")[0].strip('"')
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
|
2023-06-23 01:22:50 +01:00
|
|
|
try:
|
2023-08-13 14:18:39 +01:00
|
|
|
vm_parent = Path(get_vmpath()).parent
|
2023-06-23 01:22:50 +01:00
|
|
|
except FileNotFoundError as e:
|
2023-10-29 09:40:10 +00:00
|
|
|
raise InstallError("Unable to fetch DLL path from the registry") from e
|
2022-06-16 14:07:12 +01:00
|
|
|
|
2024-06-29 03:55:15 +01:00
|
|
|
DLL_NAME = f'VoicemeeterRemote{"64" if BITS == 64 else ""}.dll'
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
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))
|