detecting Win95/Win98/WinME

Discussion in 'Ruby' started by Joel VanderWerf, Jan 19, 2004.

  1. 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?
     
    Joel VanderWerf, Jan 19, 2004
    #1
    1. Advertising

  2. Joel VanderWerf

    Park Heesob Guest

    Hi,
    ----- Original Message -----
    From: "Joel VanderWerf" <>
    To: "ruby-talk ML" <>
    Sent: Tuesday, January 20, 2004 8:29 AM
    Subject: detecting Win95/Win98/WinME


    >
    >
    > 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?
    >
    >

    How about `ver` ?

    C:\>irb
    irb(main):001:0> `ver`
    => "\nMicrosoft Windows 2000 [Version 5.00.2195]\n"

    Regards,
    Park Heesob
     
    Park Heesob, Jan 20, 2004
    #2
    1. Advertising

  3. > irb(main):001:0> `ver`
    > => "\nMicrosoft Windows 2000 [Version 5.00.2195]\n"


    Thanks, that does the trick.
     
    Joel VanderWerf, Jan 20, 2004
    #3
  4. Joel VanderWerf

    Phil Tomson Guest

    In article <>,
    Joel VanderWerf <> wrote:
    >> irb(main):001:0> `ver`
    >> => "\nMicrosoft Windows 2000 [Version 5.00.2195]\n"

    >
    >Thanks, that does the trick.


    Hmmm... but that's not exactly cross-platform.
    Is ver available on all flavors of Windows?

    BTW: you could probably check some section of the Registry, but it's not
    very straightforward in my experience.

    Phil
     
    Phil Tomson, Jan 20, 2004
    #4
  5. Phil Tomson wrote:
    > In article <>,
    > Joel VanderWerf <> wrote:
    >
    >>>irb(main):001:0> `ver`
    >>>=> "\nMicrosoft Windows 2000 [Version 5.00.2195]\n"

    >>
    >>Thanks, that does the trick.

    >
    >
    > Hmmm... but that's not exactly cross-platform.
    > Is ver available on all flavors of Windows?


    I've tried it on ME, and Park Heesob tried it on Win2K, so now we know
    it works on two.

    Actually, this page suggests that it is standard:

    http://www.computerhope.com/verhlp.htm

    But this page is wrong about the output on ME. It says 'Windows ME
    4.90.3000', but I got something like 'Windows Millenium ...'. So I'm
    assuming it could be either.

    > BTW: you could probably check some section of the Registry, but it's not
    > very straightforward in my experience.


    I quail at the thought :(
     
    Joel VanderWerf, Jan 20, 2004
    #5
  6. Joel VanderWerf

    Guest

    Hi,

    At Tue, 20 Jan 2004 14:01:12 +0900,
    Joel VanderWerf wrote:
    > >>>irb(main):001:0> `ver`
    > >>>=> "\nMicrosoft Windows 2000 [Version 5.00.2195]\n"
    > >>
    > >>Thanks, that does the trick.

    > >
    > >
    > > Hmmm... but that's not exactly cross-platform.
    > > Is ver available on all flavors of Windows?

    >
    > I've tried it on ME, and Park Heesob tried it on Win2K, so now we know
    > it works on two.


    ver command has been available from DOS, 2.x at least AFAIK.

    However, it tells about the command interpreter but not about
    the system. It can be changed by COMSPEC.

    --
    Nobu Nakada
     
    , Jan 20, 2004
    #6
  7. Joel VanderWerf <> wrote in message news:<>...
    > 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
     
    Daniel Berger, Jan 20, 2004
    #7
  8. Joel VanderWerf

    Phil Tomson Guest

    (Daniel Berger) wrote in message news:<>...
    > Joel VanderWerf <> wrote in message news:<>...
    > > 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
    >



    What about XP? I suspect it falls somewhere in the WinNT/2000 case.

    Phil
     
    Phil Tomson, Jan 21, 2004
    #8
  9. Daniel Berger wrote:
    ...
    > This is stolen from Moonwolf's "init.rb" file (part of the win32/winbase module).


    Thanks. I'll keep that in mind in case the `ver` solution doesn't work
    out. (Or is there a strong case for using the Win32API GetVersionExA
    call anyway?)
     
    Joel VanderWerf, Jan 21, 2004
    #9
  10. Joel VanderWerf

    Guest

    Hi,

    At Wed, 21 Jan 2004 10:20:00 +0900,
    Phil Tomson wrote:
    > What about XP? I suspect it falls somewhere in the WinNT/2000 case.


    It is NT 5.1, isn't it?

    --
    Nobu Nakada
     
    , Jan 21, 2004
    #10
  11. Phil Tomson wrote:

    >
    >What about XP? I suspect it falls somewhere in the WinNT/2000 case.
    >
    >

    AFAIK, XP is NT 5.1 (major == 5, minor == 1).

    emmanuel
     
    Emmanuel Touzery, Jan 21, 2004
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vanga Sasidhar
    Replies:
    1
    Views:
    439
    Bruno Sirianni
    Apr 3, 2004
  2. Fred
    Replies:
    2
    Views:
    325
    Tom Semple
    Nov 18, 2003
  3. Tom Semple

    Python+win32all on win95?

    Tom Semple, Nov 18, 2003, in forum: Python
    Replies:
    0
    Views:
    366
    Tom Semple
    Nov 18, 2003
  4. Quadibloc
    Replies:
    12
    Views:
    1,052
    Quadibloc
    Feb 17, 2008
  5. Quadibloc
    Replies:
    15
    Views:
    663
    Quadibloc
    Feb 16, 2008
Loading...

Share This Page