This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
DUT2Curling/lib/net/helper.rb

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