Package platformids ::
Package dist ::
Package nt ::
Module windows_kernel32dll
1
2 """MS-Windows releases for the WindowsNT family.
3
4 .. note::
5
6 **ATTENTION**: The ostype == RTE_NT uses for *dist* and *distrel* it's own non-default
7 encoding, while the scheme follows the default record layout, see ':ref:`Windows NT <enumWINNT>`'.
8 """
9 from __future__ import absolute_import
10
11 import sys
12
13 from platformids import RTE_NT, RTE_WIN, RTE_WINDOWS, \
14 rte2num, num2rte, num2pretty
15
16 __author__ = 'Arno-Can Uestuensoez'
17 __license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
18 __copyright__ = "Copyright (C) 2010-2018 Arno-Can Uestuensoez" \
19 " @Ingenieurbuero Arno-Can Uestuensoez"
20 __version__ = '0.1.2'
21 __uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"
22
23 __docformat__ = "restructuredtext en"
24
25
26
27
28
29 VER_NT_WORKSTATION = 0x0000001
30 VER_NT_DOMAIN_CONTROLLER = 0x0000002
31 VER_NT_SERVER = 0x0000003
32
33 VER_NT_IOT = 0x0000004
34
35
36
37
38 if sys.platform in ('win32',):
39 import ctypes
40 kernel32 = ctypes.windll.kernel32
41
42 elif sys.platform in ('cygwin',):
43 import ctypes
44 kernel32 = ctypes.CDLL('kernel32.dll')
45
46
48 try:
49 class OSVersionInfo(ctypes.Structure):
50 _fields_ = [
51 ("dwOSVersionInfoSize" , ctypes.c_int),
52 ("dwMajorVersion" , ctypes.c_int),
53 ("dwMinorVersion" , ctypes.c_int),
54 ("dwBuildNumber" , ctypes.c_int),
55 ("dwPlatformId" , ctypes.c_int),
56 ("szCSDVersion" , ctypes.c_char * 128),
57 ]
58
59 _GetVersionEx = getattr( ctypes.windll.kernel32 , "GetVersionExA")
60 version = OSVersionInfo()
61 version.dwOSVersionInfoSize = ctypes.sizeof(OSVersionInfo)
62 _GetVersionEx( ctypes.byref(version) )
63 return version
64
65 except:
66 return
67
69 """Retuns a structure OSVERSIONINFOEXA, which contains the value
70 for wProductType.
71 """
72 try:
73 class OSVersionInfoExa(ctypes.Structure):
74 _fields_ = [
75 ("dwOSVersionInfoSize" , ctypes.c_int),
76 ("dwMajorVersion" , ctypes.c_int),
77 ("dwMinorVersion" , ctypes.c_int),
78 ("dwBuildNumber" , ctypes.c_int),
79 ("dwPlatformId" , ctypes.c_int),
80 ("szCSDVersion" , ctypes.c_char * 128),
81
82 ("wServicePackMajor" , ctypes.c_int16),
83 ("wServicePackMinor" , ctypes.c_int16),
84 ("wSuiteMask" , ctypes.c_int16),
85 ("wProductType" , ctypes.c_int8),
86
87
88
89
90
91 ("wReserved" , ctypes.c_int8),
92
93 ];
94
95 _GetVersionExa = getattr( kernel32 , "GetVersionExA")
96 version = OSVersionInfoExa()
97 version.dwOSVersionInfoSize = ctypes.sizeof(OSVersionInfoExa)
98 _GetVersionExa( ctypes.byref(version) )
99 return version
100
101 except:
102 return
103
105
106
107
108
109
110
111
112
113
114 try:
115 class OSProdInfo(ctypes.Structure):
116 _fields_ = [
117 ("pdwReturnedProductType" , ctypes.c_int),
118 ];
119
120 _GetProductInfo = getattr( kernel32 , "GetProductInfo")
121 ptype = OSProdInfo()
122 ptype.dwOSVersionInfoSize = ctypes.sizeof(OSProdInfo)
123
124 osver = get_win32_OSVersionInfoExa()
125 _GetProductInfo(
126 ctypes.c_int(osver.dwMajorVersion),
127 ctypes.c_int(osver.dwMinorVersion),
128 ctypes.c_int(osver.wServicePackMajor),
129 ctypes.c_int(osver.wServicePackMinor),
130 ctypes.byref(ptype)
131 )
132 return ptype
133
134 except:
135 return
136
138 try:
139 print("dwOSVersionInfoSize = " + str(vinfo.dwOSVersionInfoSize))
140 print("dwMajorVersion = " + str(vinfo.dwMajorVersion))
141 print("dwMinorVersion = " + str(vinfo.dwMinorVersion))
142 print("dwBuildNumber = " + str(vinfo.dwBuildNumber))
143 print("dwPlatformId = " + str(vinfo.dwPlatformId))
144 print("szCSDVersion = " + str(vinfo.szCSDVersion))
145
146 print("wServicePackMajor = " + str(vinfo.wServicePackMajor))
147 print("wServicePackMinor = " + str(vinfo.wServicePackMinor))
148 print("wSuiteMask = " + str(vinfo.wSuiteMask))
149 print("wProductType = " + str(vinfo.wProductType))
150 print("wReserved = " + str(vinfo.wReserved))
151
152 except:
153 return
154
155
157
158 try:
159
160
161
162 class OSProdInfo(ctypes.Structure):
163 _fields_ = [
164 ("pdwReturnedProductType" , ctypes.c_int),
165 ];
166
167 _IsWindowsXPSP1OrGreater = getattr( kernel32 , "IsWindowsXPSP1OrGreater")
168 return _IsWindowsXPSP1OrGreater()
169
170 except:
171 return
172