voicemeeter-rb/lib/voicemeeter/install.rb

39 lines
867 B
Ruby
Raw Normal View History

2023-07-07 02:30:05 +01:00
module Voicemeeter
private
module Install
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|
value = reg["UninstallString"]
2023-07-07 02:30:05 +01:00
Pathname.new(value).dirname
end
rescue Win32::Registry::Error => e
2023-08-02 00:14:17 +01:00
err_msg = [
"#{e.class.name}: #{e.message}",
*e.backtrace
]
logger.error err_msg.join("\n")
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