2023-07-07 02:30:05 +01:00
|
|
|
require "win32/registry"
|
|
|
|
require "pathname"
|
|
|
|
require "ffi"
|
|
|
|
|
2023-08-01 23:44:30 +01:00
|
|
|
require_relative "logger"
|
|
|
|
require_relative "errors"
|
|
|
|
|
2023-07-07 02:30:05 +01:00
|
|
|
module Voicemeeter
|
|
|
|
private
|
|
|
|
|
|
|
|
module Install
|
2023-08-01 23:44:30 +01:00
|
|
|
extend Logging
|
|
|
|
|
2023-07-14 12:01:41 +01:00
|
|
|
OS_BITS = (FFI::Platform::CPU.downcase == "x64") ? 64 : 32
|
2023-07-07 02:30:05 +01:00
|
|
|
|
2023-07-14 12:01:41 +01:00
|
|
|
def get_vmpath
|
2023-07-07 02:30:05 +01:00
|
|
|
reg_key = [
|
|
|
|
:Software,
|
2023-07-14 12:01:41 +01:00
|
|
|
((OS_BITS == 64) ? :WOW6432Node : nil),
|
2023-07-07 02:30:05 +01:00
|
|
|
:Microsoft,
|
|
|
|
:Windows,
|
|
|
|
:CurrentVersion,
|
|
|
|
:Uninstall,
|
2023-07-14 12:01:41 +01:00
|
|
|
:"VB:Voicemeeter {17359A74-1236-5467}"
|
2023-07-07 02:30:05 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
Win32::Registry::HKEY_LOCAL_MACHINE.open(
|
|
|
|
reg_key.compact.join("\\")
|
|
|
|
) do |reg|
|
2023-08-01 23:44:30 +01:00
|
|
|
value = reg["UninstallString"]
|
2023-07-07 02:30:05 +01:00
|
|
|
|
|
|
|
Pathname.new(value).dirname
|
|
|
|
end
|
2023-08-01 23:44:30 +01:00
|
|
|
rescue Win32::Registry::Error => e
|
|
|
|
logger.error "#{e.class.name}: #{e.message}"
|
|
|
|
raise Errors::VMInstallError.new "unable to read Voicemeeter path from the registry"
|
2023-07-07 02:30:05 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
module_function :get_vmpath
|
|
|
|
end
|
|
|
|
end
|