From acbc2c52cce8d9c5bcd820f14953a8c8c067cc60 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sat, 8 Jan 2022 16:07:02 +0000 Subject: [PATCH] update base, inst refactor get dll and exe path --- lib/base.ps1 | 12 ++++++------ lib/inst.ps1 | 19 ++++++------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/lib/base.ps1 b/lib/base.ps1 index 148b8dc..2ec19d1 100644 --- a/lib/base.ps1 +++ b/lib/base.ps1 @@ -16,12 +16,9 @@ Function Setup_DLL { throw [VBPathError]::new("ERROR: Couldn't get Voicemeeter path") } else { - if([Environment]::Is64BitOperatingSystem) { - $dll = Join-Path -Path $vb_path -ChildPath "VoicemeeterRemote64.dll" - } - else { - $dll = Join-Path -Path $vb_path -ChildPath "VoicemeeterRemote.dll" - } + $dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + ` + (&{If([Environment]::Is64BitOperatingSystem) {"64"} Else {""}}) + ` + ".dll") } } catch [VBPathError] { @@ -29,6 +26,9 @@ Function Setup_DLL { return $false } + + + $Signature = @" [DllImport(@"$dll")] public static extern int VBVMR_Login(); diff --git a/lib/inst.ps1 b/lib/inst.ps1 index 312156d..eae807e 100644 --- a/lib/inst.ps1 +++ b/lib/inst.ps1 @@ -1,15 +1,8 @@ Function Get_VBPath { - @( - 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall', - 'Registry::HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall' - ) | ForEach-Object { - if(Test-Path -Path $_) { - (Get-ChildItem -Path $_\*) | ForEach-Object { - if($_.Name.Contains("Voicemeeter")) { - $reg = -join("Registry::", $_.Name) - return $(Get-ItemPropertyValue -Path $reg -Name UninstallString | Split-Path -Parent) - } - } - } - } + $reg_path = "Registry::HKEY_LOCAL_MACHINE\Software" + ` + (&{If([Environment]::Is64BitOperatingSystem) {"\WOW6432Node"} Else {""}}) + ` + "\Microsoft\Windows\CurrentVersion\Uninstall" + $vm_key = "\VB:Voicemeeter {17359A74-1236-5467}\" + + return $(Get-ItemPropertyValue -Path ($reg_path + $vm_key) -Name UninstallString | Split-Path -Parent) }