8.43. dist.nt.windows_kernel32_dll

Support module for the original Windows product enumerations [doc] including additional definitions.

8.43.1. Module

MS-Windows releases for the WindowsNT family.

Note

ATTENTION: The ostype == RTE_NT uses for dist and distrel it’s own non-default encoding, while the scheme follows the default record layout, see ‘Windows NT’.

8.43.2. Data Structures

This module defines product related data structures representing the namebinding and extensions.

8.43.2.1. Product Identifiers

The list of product identifiers provided by Microsoft.

  • prod_ext

    A map of original const values defined by GetProductInfo function parameter values of pwReturnedProductType, see [GetProductInfo] and [pwReturnedProductType]. This defines a proprietary category index of cumulated product types, see Product Type Categories.

    prod_ext = {
        0x00000006: 4,   # PRODUCT_BUSINESS
        0x00000010: 4,   # PRODUCT_BUSINESS_N
        0x00000012: 4,   # PRODUCT_CLUSTER_SERVER
        0x00000040: 4,   # PRODUCT_CLUSTER_SERVER_V
        0x00000065: 4,   # PRODUCT_CORE
        ... # see Source
    

    The dict values provide the cumulative index for prod_type_categories.

8.43.2.2. Product Type Categories

A proprietary category abstraction of cumulated product types by the platformids, see Product Identifiers.

  • prod_type_categories

    A cumulative abstraction of the defined product identifiers in order to get more abstract and though less variants of products. The view is an attempt to a more technical categorization of the predefined enums.

    #
    # see Source
    #
    prod_type_categories = (
        "H",     #  0:  Home
        "HS",    #  1:  Home Server
        "WS",    #  2:  Workstation
        "D",     #  3:  Data Center
        "E",     #  4:  Enterprise Server
        "STD",   #  5:  Standard Server
        "BS",    #  6:  Basic Server: Small Business Server / Essential Server
        "VIRT",  #  7:  Virtualization
        "IOT",   #  8:  IoT
        "EDU",   #  9:  Education
        "EMB",   # 10:  Embedded
    )
    

8.43.2.3. Product Enums

The provides values by the interface parameter pwReturnedProductType [pwReturnedProductType], and their defining macros from the SDK are provided as Python constants with the same names.

PRODUCT_BUSINESS = 0x00000006
PRODUCT_BUSINESS_N = 0x00000010
PRODUCT_CLUSTER_SERVER = 0x00000012
... # see Source

8.43.3. Functions

The following specific functions are available on the platforms of “category == Windows” including “Cygwin”. The functions provide access to the native API of the platform library “kernel32.dll”.

8.43.3.1. get_win32_OSVersionInfo

platformids.dist.nt.windows_kernel32dll.get_win32_OSVersionInfo()[source]

Gets the system information, by mapping the call onto GetVersionExA. See original GetVersionExA function description [GetVersionExA].

Args:

None

Returns:

The ctypes.Structure for current platform

class OSVersionInfo(ctypes.Structure):
   _fields_ = [
       ("dwOSVersionInfoSize" , ctypes.c_int),        # DWORD
       ("dwMajorVersion"      , ctypes.c_int),        # DWORD
       ("dwMinorVersion"      , ctypes.c_int),        # DWORD
       ("dwBuildNumber"       , ctypes.c_int),        # DWORD
       ("dwPlatformId"        , ctypes.c_int),        # DWORD
       ("szCSDVersion"        , ctypes.c_char * 128), # CHAR
   ]

when on RTE_NT, returns None else.

Raises:

pass-through

8.43.3.2. get_win32_OSVersionInfoExa

platformids.dist.nt.windows_kernel32dll.get_win32_OSVersionInfoExa()[source]

Retuns a structure OSVERSIONINFOEXA, which contains the value for wProductType.

Gets the system information, by mapping the call onto OSVersionInfoExa. See original OSVersionInfoExa function description [OSVERSIONINFOEXA].

Args:

None

Returns:

The ctypes.Structure for current platform

class OSVersionInfoExa(ctypes.Structure):
   _fields_ = [
       ("dwOSVersionInfoSize" , ctypes.c_int),        # DWORD
       ("dwMajorVersion"      , ctypes.c_int),        # DWORD
       ("dwMinorVersion"      , ctypes.c_int),        # DWORD
       ("dwBuildNumber"       , ctypes.c_int),        # DWORD
       ("dwPlatformId"        , ctypes.c_int),        # DWORD
       ("szCSDVersion"        , ctypes.c_char * 128), # CHAR

       ("wServicePackMajor"   , ctypes.c_int16),      # WORD
       ("wServicePackMinor"   , ctypes.c_int16),      # WORD
       ("wSuiteMask"          , ctypes.c_int16),      # WORD
       ("wProductType"        , ctypes.c_int8),       # BYTE
           # wProductType - one of:
           # - VER_NT_DOMAIN_CONTROLLER
           # - VER_NT_SERVER
           # - VER_NT_WORKSTATION
           #
       ("wReserved"           , ctypes.c_int8),       # BYTE

       ];

when on RTE_NT, returns None else.

Raises:

pass-through

8.43.3.3. get_win32_OSProductInfo

platformids.dist.nt.windows_kernel32dll.get_win32_OSProductInfo()[source]

Gets the system information, by mapping the call onto OSProductInfo. See original OSProductInfo function description [OSProductInfo].

Args:

None

Returns:

The ctypes.Structure for current platform

class OSProdInfo(ctypes.Structure):
   _fields_ = [
       ("pdwReturnedProductType" , ctypes.c_int),        # PDWORD
       ];

when on RTE_NT, returns None else.

Raises:

pass-through

8.43.3.5. get_win32_IsWindowsXPSP1OrGreater

platformids.dist.nt.windows_kernel32dll.get_win32_IsWindowsXPSP1OrGreater()[source]

Checks the system information, by mapping the call onto IsWindowsXPSP1OrGreater. See original IsWindowsXPSP1OrGreater function description [IsWindowsXPSP1OrGreater].

Args:

None

Returns:

The ctypes.Structure for current platform

class OSProdInfo(ctypes.Structure):
   _fields_ = [
       ("pdwReturnedProductType" , ctypes.c_int),        # PDWORD
       ];

when on RTE_NT, returns None else.

Raises:

pass-through

8.43.4. Source

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# -*- coding: utf-8 -*-
"""MS-Windows releases for the WindowsNT family.

.. note::

   **ATTENTION**: The ostype == RTE_NT uses for *dist* and *distrel* it's own non-default 
   encoding, while the scheme follows the default record layout, see ':ref:`Windows NT <enumWINNT>`'.
"""
from __future__ import absolute_import

import sys

from platformids import RTE_NT, RTE_WIN, RTE_WINDOWS, \
    rte2num, num2rte, num2pretty

__author__ = 'Arno-Can Uestuensoez'
__license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
__copyright__ = "Copyright (C) 2010-2018 Arno-Can Uestuensoez" \
                " @Ingenieurbuero Arno-Can Uestuensoez"
__version__ = '0.1.2'
__uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"

__docformat__ = "restructuredtext en"


#
# Microsoft: OSVERSIONINFOEXA.wProductType
#
VER_NT_WORKSTATION       = 0x0000001  #: see wProductType
VER_NT_DOMAIN_CONTROLLER = 0x0000002  #: see wProductType
VER_NT_SERVER            = 0x0000003  #: see wProductType

VER_NT_IOT               = 0x0000004  #: non standard enum

#
# platform specific adapters: win/nt and cygwin
#
if sys.platform in ('win32',):
    import ctypes
    kernel32 = ctypes.windll.kernel32  # @UndefinedVariable

elif sys.platform in ('cygwin',):
    import ctypes  # @Reimport
    kernel32 = ctypes.CDLL('kernel32.dll')


def get_win32_OSVersionInfo():   
    try:
        class OSVersionInfo(ctypes.Structure):
            _fields_ = [
                ("dwOSVersionInfoSize" , ctypes.c_int),        # DWORD
                ("dwMajorVersion"      , ctypes.c_int),        # DWORD
                ("dwMinorVersion"      , ctypes.c_int),        # DWORD
                ("dwBuildNumber"       , ctypes.c_int),        # DWORD
                ("dwPlatformId"        , ctypes.c_int),        # DWORD
                ("szCSDVersion"        , ctypes.c_char * 128), # CHAR
            ]
    
        _GetVersionEx = getattr( ctypes.windll.kernel32 , "GetVersionExA")  # @UndefinedVariable
        version  = OSVersionInfo()
        version.dwOSVersionInfoSize = ctypes.sizeof(OSVersionInfo)
        _GetVersionEx( ctypes.byref(version) )    
        return version

    except:
        return
    
def get_win32_OSVersionInfoExa():
    """Retuns a structure OSVERSIONINFOEXA, which contains the value
    for wProductType.
    """
    try:
        class OSVersionInfoExa(ctypes.Structure):
            _fields_ = [
                ("dwOSVersionInfoSize" , ctypes.c_int),        # DWORD
                ("dwMajorVersion"      , ctypes.c_int),        # DWORD
                ("dwMinorVersion"      , ctypes.c_int),        # DWORD
                ("dwBuildNumber"       , ctypes.c_int),        # DWORD
                ("dwPlatformId"        , ctypes.c_int),        # DWORD
                ("szCSDVersion"        , ctypes.c_char * 128), # CHAR

                ("wServicePackMajor"   , ctypes.c_int16),      # WORD
                ("wServicePackMinor"   , ctypes.c_int16),      # WORD
                ("wSuiteMask"          , ctypes.c_int16),      # WORD
                ("wProductType"        , ctypes.c_int8),       # BYTE
                    # wProductType - one of:
                    # - VER_NT_DOMAIN_CONTROLLER
                    # - VER_NT_SERVER
                    # - VER_NT_WORKSTATION
                    #
                ("wReserved"           , ctypes.c_int8),       # BYTE

                ];

        _GetVersionExa = getattr( kernel32 , "GetVersionExA")
        version  = OSVersionInfoExa()
        version.dwOSVersionInfoSize = ctypes.sizeof(OSVersionInfoExa)
        _GetVersionExa( ctypes.byref(version) )
        return version

    except:
        return

def get_win32_OSProductInfo():   

        # BOOL WINAPI GetProductInfo(
        #   _In_  DWORD  dwOSMajorVersion,
        #   _In_  DWORD  dwOSMinorVersion,
        #   _In_  DWORD  dwSpMajorVersion,
        #   _In_  DWORD  dwSpMinorVersion,
        #   _Out_ PDWORD pdwReturnedProductType
        # );

    try:
        class OSProdInfo(ctypes.Structure):
            _fields_ = [
                ("pdwReturnedProductType" , ctypes.c_int),        # PDWORD
                ];

        _GetProductInfo = getattr( kernel32 , "GetProductInfo")
        ptype  = OSProdInfo()
        ptype.dwOSVersionInfoSize = ctypes.sizeof(OSProdInfo)

        osver = get_win32_OSVersionInfoExa()
        _GetProductInfo(
            ctypes.c_int(osver.dwMajorVersion),
            ctypes.c_int(osver.dwMinorVersion),
            ctypes.c_int(osver.wServicePackMajor),
            ctypes.c_int(osver.wServicePackMinor),
            ctypes.byref(ptype) 
            )
        return ptype

    except:
        return

def print_versinfo(vinfo):
    try:
        print("dwOSVersionInfoSize  = " + str(vinfo.dwOSVersionInfoSize))
        print("dwMajorVersion       = " + str(vinfo.dwMajorVersion))
        print("dwMinorVersion       = " + str(vinfo.dwMinorVersion))
        print("dwBuildNumber        = " + str(vinfo.dwBuildNumber))
        print("dwPlatformId         = " + str(vinfo.dwPlatformId))
        print("szCSDVersion         = " + str(vinfo.szCSDVersion))

        print("wServicePackMajor    = " + str(vinfo.wServicePackMajor))
        print("wServicePackMinor    = " + str(vinfo.wServicePackMinor))
        print("wSuiteMask           = " + str(vinfo.wSuiteMask))
        print("wProductType         = " + str(vinfo.wProductType))
        print("wReserved            = " + str(vinfo.wReserved))

    except:
        return


def get_win32_IsWindowsXPSP1OrGreater():   

    try:
        # BOOL WINAPI  IsWindowsXPSP1OrGreater(
        # );

        class OSProdInfo(ctypes.Structure):
            _fields_ = [
                ("pdwReturnedProductType" , ctypes.c_int),        # PDWORD
                ];

        _IsWindowsXPSP1OrGreater = getattr( kernel32 , "IsWindowsXPSP1OrGreater")
        return _IsWindowsXPSP1OrGreater()

    except:
        return

8.43.5. Download

windows_kernel32dll.py

8.43.6. Resources