Module: Voicemeeter::Install

Extended by:
Logging
Defined in:
lib/voicemeeter/install.rb

Constant Summary collapse

OS_BITS =
(FFI::Platform::CPU.downcase == "x64") ? 64 : 32

Class Method Summary collapse

Methods included from Logging

logger

Class Method Details

.get_vmpathObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/voicemeeter/install.rb', line 9

def get_vmpath
  reg_key = [
    :Software,
    ((OS_BITS == 64) ? :WOW6432Node : nil),
    :Microsoft,
    :Windows,
    :CurrentVersion,
    :Uninstall,
    :"VB:Voicemeeter {17359A74-1236-5467}"
  ]

  Win32::Registry::HKEY_LOCAL_MACHINE.open(
    reg_key.compact.join("\\")
  ) do |reg|
    value = reg["UninstallString"]

    Pathname.new(value).dirname
  end
rescue Win32::Registry::Error => e
  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"
end