win9x or WinNT

Nicodemus nicodemus at icablenet.com.br
Sun Aug 4 10:26:52 CEST 2002


If you are just interested in the difference between win9x and NT/2000, you
can use os.name instead.

>>> import os
>>> os.name
'nt'


Nicodemus.

----- Original Message -----
From: "Evgeny Pedya" <john at ablogic.ru>
To: <python-list at python.org>
Sent: Saturday, August 03, 2002 7:08 PM
Subject: Re: win9x or WinNT


> Hello, Thomas!
> You wrote in conference comp.lang.python to <python-list at python.org> on
Wed,
> 31 Jul 2002 18:22:01 +0200:
>
>  TG> How can a python programm know if it runs on win9x or on WinNT?
>  TG> sys.platform always returns win32.
>  TG> I need to handle some stuff different if I am on win9x.
>  TG>   thomas
>
> Maybe something like this:
>
> -----------------------------------------------------------
> import win32api
>
> os_ver_data = win32api.GetVersionEx()
>
> if os_ver_data[3] == 1:
>    print "Simple Windows:"
>    if os_ver_data[1] == 0:
>       print "Windows 95"
>    elif os_ver_data[1] == 10:
>       print "Windows 98"
>    print "bild: " + str(os_ver_data[2])
>    print "info: " + os_ver_data[4]
> elif os_ver_data[3] == 2:
>    print "Windows NT:"
>    if os_ver_data[0] == 3:
>       print "Windows NT 3.51"
>    elif os_ver_data[0] == 4:
>       print "Windows NT 4"
>    elif os_ver_data[0] == 5:
>       if os_ver_data[1] == 0:
>          print "Windows 2000"
>       elif os_ver_data[1] == 1:
>          print "Windows XP/.NET Server"
>    print "bild: " + str(os_ver_data[2])
>    print "info: " + os_ver_data[4]
> else:
>    print "Unknown windOwS"
> -----------------------------------------------------------
>
> With best regards, Evgeny Pedya.
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list