win9x or WinNT

Evgeny Pedya john at ablogic.ru
Sun Aug 4 05:08:32 CEST 2002


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.






More information about the Python-list mailing list