diff --git a/lib/voicemeeter/install.rb b/lib/voicemeeter/install.rb index 18d2b86..441cbea 100644 --- a/lib/voicemeeter/install.rb +++ b/lib/voicemeeter/install.rb @@ -2,10 +2,15 @@ require "win32/registry" require "pathname" require "ffi" +require_relative "logger" +require_relative "errors" + module Voicemeeter private module Install + extend Logging + OS_BITS = (FFI::Platform::CPU.downcase == "x64") ? 64 : 32 def get_vmpath @@ -22,10 +27,13 @@ module Voicemeeter Win32::Registry::HKEY_LOCAL_MACHINE.open( reg_key.compact.join("\\") ) do |reg| - value = reg[:UninstallString.to_s] + value = reg["UninstallString"] Pathname.new(value).dirname end + rescue Win32::Registry::Error => e + logger.error "#{e.class.name}: #{e.message}" + raise Errors::VMInstallError.new "unable to read Voicemeeter path from the registry" end module_function :get_vmpath