Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > detecting Win95/Win98/WinME

Reply
Thread Tools

detecting Win95/Win98/WinME

 
 
Joel VanderWerf
Guest
Posts: n/a
 
      01-19-2004

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?



 
Reply With Quote
 
 
 
 
Park Heesob
Guest
Posts: n/a
 
      01-20-2004
Hi,
----- Original Message -----
From: "Joel VanderWerf" <(E-Mail Removed)>
To: "ruby-talk ML" <(E-Mail Removed)>
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




 
Reply With Quote
 
 
 
 
Joel VanderWerf
Guest
Posts: n/a
 
      01-20-2004
> irb(main):001:0> `ver`
> => "\nMicrosoft Windows 2000 [Version 5.00.2195]\n"


Thanks, that does the trick.



 
Reply With Quote
 
Phil Tomson
Guest
Posts: n/a
 
      01-20-2004
In article <(E-Mail Removed)>,
Joel VanderWerf <(E-Mail Removed)> 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
 
Reply With Quote
 
Joel VanderWerf
Guest
Posts: n/a
 
      01-20-2004
Phil Tomson wrote:
> In article <(E-Mail Removed)>,
> Joel VanderWerf <(E-Mail Removed)> 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



 
Reply With Quote
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      01-20-2004
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


 
Reply With Quote
 
Daniel Berger
Guest
Posts: n/a
 
      01-20-2004
Joel VanderWerf <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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').c all(buf)
if b != 0
(size,major,minor,build,platform,version)=buf.unpa ck("LLLLLA128")
WINVER = (major << | 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
 
Reply With Quote
 
Phil Tomson
Guest
Posts: n/a
 
      01-21-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Daniel Berger) wrote in message news:<(E-Mail Removed). com>...
> Joel VanderWerf <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> > 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').c all(buf)
> if b != 0
> (size,major,minor,build,platform,version)=buf.unpa ck("LLLLLA128")
> WINVER = (major << | 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
 
Reply With Quote
 
Joel VanderWerf
Guest
Posts: n/a
 
      01-21-2004
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?)



 
Reply With Quote
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      01-21-2004
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting end of file for VHDL'93 Gary Thorpe VHDL 2 07-12-2005 07:42 AM
Detecting if Mozilla is Running Peter Firefox 1 04-30-2005 09:47 PM
Detecting edge in a clock synchronous porcess Praveen VHDL 2 04-12-2005 11:36 AM
Detecting of 'U' in a std_logic_vector Thomas Reinemann VHDL 4 11-03-2004 08:24 AM
detecting if program is running under X windows or not Paul Faulstich Perl 1 01-10-2004 07:16 PM



Advertisments