summaryrefslogtreecommitdiff
path: root/ext/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-18 01:10:22 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-18 01:10:22 (GMT)
commit1c98a41ae3f1f4bea2fa0449b0771f5de68328f2 (patch)
tree5595f8e4a0a87a52dcb549a236174574cf03c55c /ext/win32
parentf729089f44ec2911d5a668c114b749c45d3df0f6 (diff)
win32/resolv.rb: call rb_w32_osid
* ext/win32/lib/win32/resolv.rb: call rb_w32_osid instead of direct GetVersionExA API. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32')
-rw-r--r--ext/win32/lib/win32/resolv.rb25
1 files changed, 12 insertions, 13 deletions
diff --git a/ext/win32/lib/win32/resolv.rb b/ext/win32/lib/win32/resolv.rb
index 340a9b9..1eb70d5 100644
--- a/ext/win32/lib/win32/resolv.rb
+++ b/ext/win32/lib/win32/resolv.rb
@@ -42,19 +42,19 @@ begin
rescue LoadError
end
-nt = Module.new do
- break true if [nil].pack("p").size > 4
- extend Importer
- dlload "kernel32.dll"
- getv = extern "int GetVersionExA(void *)", :stdcall
- info = [ 148, 0, 0, 0, 0 ].pack('V5') + "\0" * 128
- getv.call(info)
- break info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
+if [nil].pack("p").size <= 4 # 32bit env
+ begin
+ f = Fiddle
+ osid = f::Handle.new["rb_w32_osid"]
+ rescue f::DLError # not ix86, cannot be Windows 9x
+ else
+ if f::Function.new(osid, [], f::TYPE_INT).call < 2 # VER_PLATFORM_WIN32_NT
+ require_relative 'resolv9x'
+ return
+ end
+ end
end
-if not nt
- require_relative 'resolv9x'
- # return # does not work yet
-else
+
module Win32
#====================================================================
# Windows NT
@@ -146,4 +146,3 @@ module Win32
end
end
end
-end