d2a45c0be2
new file: c/ff new file: c/main.rb new file: lib/gtk2.rb new file: lib/gtk2/base.rb new file: lib/net/external.rb new file: lib/net/helper.rb new file: lib/net/http.rb new file: lib/net/icmp.rb new file: lib/net/ping.rb new file: lib/net/tcp.rb new file: lib/net/udp.rb new file: lib/net/wmi.rb new file: m/ReadFile.rb new file: v/Vue1.rb new file: v/VueError.rb
34 lines
463 B
Ruby
34 lines
463 B
Ruby
require 'ffi'
|
|
|
|
module Windows
|
|
extend FFI::Library
|
|
ffi_lib :kernel32
|
|
|
|
attach_function :GetVersion, [], :ulong
|
|
|
|
def version
|
|
version = GetVersion()
|
|
major = LOBYTE(LOWORD(version))
|
|
minor = HIBYTE(LOWORD(version))
|
|
eval("Float(#{major}.#{minor})")
|
|
end
|
|
|
|
private
|
|
|
|
class << self
|
|
def LOWORD(l)
|
|
l & 0xffff
|
|
end
|
|
|
|
def LOBYTE(w)
|
|
w & 0xff
|
|
end
|
|
|
|
def HIBYTE(w)
|
|
w >> 8
|
|
end
|
|
end
|
|
|
|
module_function :version
|
|
end
|