in reply to split OSVersion in two categories

how can i get Oses NT 4 and Vista when they have the same minor and id

By looking at the major part of the version.

use constant VER_PLATFORM_WIN32_WINDOWS => 1; # Win9x line use constant VER_PLATFORM_WIN32_NT => 2; # WinNT line use constant VER_NT_WORKSTATION => 1; my %oses = ( '9x 4.0 ???' => '95', '9x 4.10 ???' => '98 or 98 SE', '9x 4.90 ???' => 'Me', 'NT 3.51 ???' => 'NT3.51', 'NT 4.? ???' => 'NT4', 'NT 5.0 WS' => '2000', 'NT 5.1 WS' => 'XP', 'NT 5.2 ???' => 'XP Professional x64 Edition, ' .'Server 2003, ' .'Server 2003 R2 or ' .'Home Server', 'NT 6.0 WS' => 'Vista', 'NT 6.0 !WS' => 'Server 2008', 'NT 6.1 WS' => '7', 'NT 6.1 !WS' => 'Server 2008 R2', ); my ($id, $major, $minor, $prod_type) = ( Win32::GetOSVersion() )[4,1,2,8]; my $id_str = join(' ', $id == VER_PLATFORM_WIN32_NT ? 'NT' : '9x', "$major.$minor", $prod_type == VER_NT_WORKSTATION ? 'WS' : '!WS' ], ); my $os = $oses{$id_str};

(Replace the "???" with the missing information.)

See Getting the System Version. OSVERSIONINFOEX is also interesting.

Replies are listed 'Best First'.
Re^2: split OSVersion in two categories
by nico7nibor (Novice) on Nov 20, 2009 at 08:05 UTC

    (Replace the "???" with the missing information.)

    Where can I check to replace the "???" missing information?, the code bdw works, thanks.... it seems ok even with <???>, can i leave it that way or delete, would that still be ok?

    sorry im lost about to replace the missing string

    thanks again..
      It won't work if you're on one of the systems that has "???" in its key. You could get the info by running GetOSVersion on those systems.

        Thanks, il try to check the other system with old OSes...

        I have one more qn, with regards to ($id, $major, $minor, $prod_type) = ( Win32::GetOSVersion() )4,1,2,8;

        what does the numbers 4,1,2,8 mean, esp number 8. I know it has something to do with the prodtype but i cant seem comprehend the logic

        thanks