To find out it it's Windows Me or Windows 98 or Windows 95, you'd need somthing like this:my @winver = Win32::GetOSVersion(); print "Windows 2000" if $winver[1] == 5 and $winver[4] == 2;
Alternatively, you could build a lookup:# I'm guessing at the major Windows versions for 9x here, but it shoul +d be easy to test: print "Windows 95" if $winver[1] == 1 and $winver[4] == 1; print "Windows 98" if $winver[1] == 2 and $winver[4] == 1; print "Windows Me" if $winver[1] == 3 and $winver[4] == 1;
My point is here, that there are loads of ways of doing this, but this way is much better than using the output of "ver" You get all the imformation that "ver" gives but in a way that makes it easy to use without a regex. Plus it's easily extendible - XP is out this month, I'd be willing to bet that you could detect XP like this: (or something very similar)my $version_lookup = [ [], # Win32s (not sure what goes here) [ undef, "Windows95", "Windows98", "WindowsMe" ], [ undef, undef, undef, "NT 3", "NT 4", "Windows 2000"] ]; my @winver = Win32::GetOSVersion(); printf "Operating System is %s", $version_lookup->[$winver[4]]->[$winv +er[1]];
Do you know what the output of ver will be for Windows XP?print "I'm XP!!" if $winver[1] == 6 and $winver[4] == 2;
In reply to Re: Re: Re: Windows Version Detection
by $code or die
in thread Windows Version Detection
by jlongino
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |