Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Determine Windows Type or Version

by demerphq (Chancellor)
on Feb 11, 2002 at 17:56 UTC ( [id://144660]=CUFP: print w/replies, xml ) Need Help??

Use to determine the name of the windows OS that is being used. Currently handles win32s, 95, 98, Me, NT3.51, NT4, 2000,and XP/.Net. (In fact these strings are what it returns). Returns undef or () if the OS is not a Windows Box of some sort. The determination of the OS is done through the Win32 module and the API call GetOSVersion. Parsing the results is according to the specs of this function in MSDN. The snippet will try to require 'Win32' on its own if it is running on a Windows box. If it cant get Win32 it returns undef as well. Comments/Criticism, bugfixes welcome! Yves/Demerphq
sub Win_OS_Type { return unless $^O =~ /win32|dos/i; # is it a MS box? # It _should_ have Win32 unless something is really weird return unless eval('require Win32'); # Use the standard API call to determine the version my ( undef, $major, $minor, $build, $id ) = Win32::GetOSVersion; return "win32s" unless $id; # If id==0 then its a win32s + box. my $os = { # Magic numbers from MSDN do +cumentation of GetOSVersion 1 => { 0 => "95", 10 => "98", 90 => "Me" }, 2 => { 0 => "2000", 1 => "XP/.Net", 51 => "NT3.51" } }->{$id}->{$minor}; # This _really_ shouldnt happen. At least not for quite a while die "$id:$major:$minor Has no name of record!" unless defined $os; # Unfortunately the logic used for the various versions isnt so cl +ever.. # so we have to handle an outside case. return ( $os eq "2000" & $major != 5 ) ? "NT4" : $os; }

Replies are listed 'Best First'.
Re: Determine Windows Type or Version
by demerphq (Chancellor) on Jun 24, 2002 at 10:08 UTC
    This node/code is deprecated.

    Please install ActiveState Build 633, it comes with a function called Win32::GetOSName()

    Yves / DeMerphq
    ---
    Writing a good benchmark isnt as easy as it might look.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://144660]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2024-04-23 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found