From: djberg96@... (Daniel Berger) Date: 2004-01-21T02:15:06+09:00 Subject: Re: detecting Win95/Win98/WinME Joel VanderWerf wrote in message news:<400C6835.1010203@path.berkeley.edu>... > Some of the File#flock arguments do not work on Win95/Win98/WinME > (namely LOCK_SH and LOCK_NB), so I'm looking for a way to detect what > kind of windows the process is running on. RUBY_PLATFORM and rbconfig.rb > do not seem to help. > > Any ideas? This is stolen from Moonwolf's "init.rb" file (part of the win32/winbase module). require "Win32API" buf = [148].pack("L")+"\0"*144 b = Win32API.new('kernel32','GetVersionExA','P','I').call(buf) if b != 0 (size,major,minor,build,platform,version)=buf.unpack("LLLLLA128") WINVER = (major << 8) | minor WINVER_MAJOR = major WINVER_MINOR = minor WINVER_BUILD = build WIN32_WINDOWS = WINVER case platform when 0 #Win32s WINVER_OSNAME = "Win32s" WINPLATFORM = "Win32s" UNICODE = false WIN32_IE = 0x000 when 1 #Win95/98 WINPLATFORM = "Win95" UNICODE = false if minor==0 #Win95 if build >= 1212 #Win95OSR2.5 WINVER_OSNAME = "Win95OSR2.5" WIN32_IE = 0x300 elsif build >= 1111 #Win95OSR2 WINVER_OSNAME = "Win95OSR2" WIN32_IE = 0x300 else #Win95 WINVER_OSNAME = "Win95" WIN32_IE = 0x200 end else #Win98/98SE/Me case minor when 0x10 #98/98SE if build>=2222 #98SE WINVER_OSNAME = "Win98SE" WIN32_IE = 0x400 else #98 WINVER_OSNAME = "Win98" WIN32_IE = 0x400 end when 0x90 #Me WINVER_OSNAME = "WinMe" WIN32_IE = 0x500 else WINVER_OSNAME = "Win98???" WIN32_IE = 0x400 end end when 2 #WinNT/2000 WINPLATFORM = "WinNT" if major==4 #WinNT4 WINVER_OSNAME = "WinNT4" UNICODE = true WIN32_IE = 0x300 elsif major==5 #Win2000 WINVER_OSNAME = "Win2000" UNICODE = true WIN32_IE = 0x400 else #WinNT3.5 WINVER_OSNAME = "WinNT3.x???" UNICODE = true WIN32_IE = 0x000 end end else WINVER_OSNAME = "???" UNICODE = false WINVER = 0x400 WIN32_WINDOWS = 0x400 WIN32_IE = 0x300 end puts WINVER_OSNAME Regards, Dan