Module: Ryb::Windows

Defined in:
lib/ryb/windows.rb

Constant Summary collapse

POSSIBLE_SDK_INSTALL_DIRECTORY_REGISTRY_KEYS =
["SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows",
"SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows"]

Class Method Summary collapse

Class Method Details

.sdkObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/ryb/windows.rb', line 7

def self.sdk
  if Ryb.platform == :windows
    if ENV.key?('WindowsSdkDir')
      ENV['WindowsSdkDir']
    else
      # TODO(mtwilliams): Escape, i.e. .gsub(/\\/,'/').gsub(/\ /,'\\ ')?

      self.sdks.first
    end
  end
end

.sdk?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ryb/windows.rb', line 18

def self.sdk?
  !self.sdk.nil?
end

.sdksObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ryb/windows.rb', line 22

def self.sdks
  if Ryb.platform == :windows
    require 'win32/registry'
    @sdks ||= begin
      (POSSIBLE_SDK_INSTALL_DIRECTORY_REGISTRY_KEYS.map do |key|
        begin
          ::Win32::Registry::HKEY_CURRENT_USER.open(key, ::Win32::Registry::KEY_READ)['CurrentInstallFolder']
        rescue
          begin
            ::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, ::Win32::Registry::KEY_READ)['CurrentInstallFolder']
          rescue
          end
        end
      end).compact
    end
  end
end