vdfsplat / AppSrc / cOSVersionInfo.pkg @ 59
History | View | Annotate | Download (21.2 KB)
1 | 14 | wil | //**************************************************************************** |
---|---|---|---|
2 | // $Module type: Package |
||
3 | // $Module name: cOSVersionInfo |
||
4 | // $Author : Wil van Antwerpen |
||
5 | // Created : 2010-05-04 |
||
6 | // License : LGPL |
||
7 | // |
||
8 | // Usage : In its most bare form you would call it to retrieve the string that |
||
9 | // sums up all of the OS capabilities for your host like this: |
||
10 | // |
||
11 | // Function HostOS Returns String |
||
12 | // Handle hoVersionInfo |
||
13 | // String sOSVersion |
||
14 | // |
||
15 | // Move "" To sOSVersion |
||
16 | // Get Create U_cOSVersionInfo To hoVersionInfo |
||
17 | // If (hoVersionInfo) Begin |
||
18 | // Get OSVersion Of hoVersionInfo To sOSVersion |
||
19 | // End |
||
20 | // |
||
21 | // Function_Return sOSVersion |
||
22 | // End_Function // HostOS |
||
23 | // |
||
24 | // Comment : This package is based on the regcheck package from http://www.vdf-guidance.com |
||
25 | // The OS detection logic has been extracted from there and put in here. |
||
26 | // It has been rewritten in a way that makes it more versatile and easier to use. |
||
27 | // |
||
28 | // The property peOSVersion should be used if you want to run code that depends |
||
29 | // on a specific OS version. |
||
30 | // |
||
31 | // |
||
32 | // Current Limitations, the code does not check for Hyper-V roles or |
||
33 | // if windows is licensed, or if the Vista Version used is Ultimate or |
||
34 | // Professional. For that we will need to use the GetProductInfo WinAPI |
||
35 | // call. (Vista and up) Knowing the OS version is Vista is OK for now. |
||
36 | // |
||
37 | // *********************************************************************** |
||
38 | Use Windows |
||
39 | Use cOSVersionInfo.h |
||
40 | use cWinKernEx.h // Package from the cWindowsEx project |
||
41 | Use cSystemInfo.pkg |
||
42 | |||
43 | |||
44 | Class cOSVersionInfo Is a cObject |
||
45 | Procedure Construct_Object |
||
46 | Forward Send Construct_Object |
||
47 | |||
48 | // The next properties return info about the Operating System. |
||
49 | // They are set by the procedure DoGetVersionInfo, which is send from |
||
50 | // the automatically invoked DoCheckWindowsVersion. |
||
51 | // |
||
52 | // Identifies the major version number of the operating system. |
||
53 | // For example, for Windows NT version 3.51, the major version number is 3; |
||
54 | // and for Windows NT version 4.0, the major version number is 4. |
||
55 | Property Integer piMajorVersion 0 |
||
56 | // Identifies the minor version number of the operating system. For example, |
||
57 | // for Windows NT version 3.51, the minor version number is 51; and for |
||
58 | // Windows NT version 4.0, the minor version number is 0. |
||
59 | // For Windows 95, dwMinorVersion is zero. |
||
60 | // For Windows 98, dwMinorVersion is greater than zero. |
||
61 | Property Integer piMinorVersion 0 |
||
62 | // Identifies the build number of the operating system. |
||
63 | Property Integer piBuildNumber 0 |
||
64 | // Identifies the operating system platform. This member can be one of the |
||
65 | // following values: |
||
66 | // CP_VER_PLATFORM_WIN32s Win32s on Windows 3.1. |
||
67 | // CP_VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95 or Windows 98. |
||
68 | // CP_VER_PLATFORM_WIN32_NT Win32 on Windows NT. |
||
69 | Property Integer piPlatFormId 0 |
||
70 | // Windows NT: Contains a string, such as "Service Pack 3", |
||
71 | // that indicates the latest Service Pack installed on the system. If no |
||
72 | // Service Pack has been installed, the string is empty. |
||
73 | // Windows 95: Contains a null-terminated string that provides arbitrary |
||
74 | // additional information about the operating system. |
||
75 | Property String psCSDVersion '' |
||
76 | // PHvW 20/04/2002 14:37 |
||
77 | // Identifies the major version number of the latest Service Pack installed |
||
78 | // on the system. For example, for Service Pack 3, the major version |
||
79 | // number is 3. If no Service Pack has been installed, the value is zero. |
||
80 | Property Integer piServicePackMajor 0 |
||
81 | // PHvW 20/04/2002 14:37 |
||
82 | // Identifies the minor version number of the latest Service Pack installed |
||
83 | // on the system. For example, for Service Pack 3, the minor version |
||
84 | // number is 0. |
||
85 | Property Integer piServicePackMinor 0 |
||
86 | // PHvW 20/04/2002 14:37 |
||
87 | // A set of bit flags that identify the product suites available on the system. |
||
88 | // This member can be a combination of the following values. (see msdn) |
||
89 | Property Integer piSuiteMask 0 |
||
90 | // |
||
91 | // The psSuite string only contains features which can be enabled or not, so it is NOT |
||
92 | // a direct mapping to piSuiteMask. An example of this is if you are in a remote desktop |
||
93 | // session or not. |
||
94 | Property String psSuite "" |
||
95 | // The Edition string contains specific details about the platform that cannot be |
||
96 | // enabled as a role. So "Home" Edition or "Datacenter" edition are good examples. |
||
97 | // R2 is a peOSVersion |
||
98 | Property String psEdition "" |
||
99 | // PHvW 20/04/2002 14:37 |
||
100 | // Indicates additional information about the system. This member can be |
||
101 | // one of the following values. VER_NT_WORKSTATION, VER_NT_SERVER, VER_NT_DOMAIN_CONTROLLER |
||
102 | Property Integer piProductType 0 |
||
103 | // PHvW 22/04/2002 17:48 |
||
104 | // Contains which version of windows is running as a text. |
||
105 | // If it can not sort it out it will be CS_OSVERSION_UNKNOWN (="Windows Version UNKNOWN") |
||
106 | Property String psOSVersion CS_OSVERSION_UNKNOWN |
||
107 | Property Integer peOSVersion CE_OSVERSION_UNKNOWN |
||
108 | // PHvW 22/04/2002 17:50 |
||
109 | // Running windows version is a server version |
||
110 | Property Boolean pbNTServer False |
||
111 | // PHvW 22/04/2002 17:50 |
||
112 | // Running on a Windows HOME version. That is Windows ME and Windows XP Home |
||
113 | // Both are not recommended platforms for business (networking is limited). |
||
114 | // So not for vdf. |
||
115 | Property Boolean pbWindowsHome False |
||
116 | // pbX64 is set to true if your host OS is x64 |
||
117 | Property Boolean pbX64 False |
||
118 | // pbRemoteDesktop is set to true if your application currently runs under a remote desktop session |
||
119 | Property Boolean pbRemoteDesktop False |
||
120 | |||
121 | Property Boolean pbAdminRights False |
||
122 | End_Procedure // Construct_Object |
||
123 | |||
124 | |||
125 | |||
126 | // Procedure sets OS info properties defined in this class |
||
127 | // The static variables and the structure used are declared in prnt_dlg.pkg. |
||
128 | Procedure DoGetVersionInfo |
||
129 | Integer iRetval |
||
130 | String sOSVersionInfo sCSDVersion |
||
131 | Pointer pOSVersionInfo |
||
132 | |||
133 | FillType _OSVERSIONINFO With 0 To sOSVersionInfo |
||
134 | Put _OSVERSIONINFO_Size To sOSVersionInfo At _OSVERSIONINFO.dwOSVersionInfoSize |
||
135 | GetAddress Of sOSVersionInfo To pOSVersionInfo |
||
136 | Move (GetVersionEx(pOSVersionInfo)) To iRetval // Function in Prnt_Dlg.pkg |
||
137 | Indicate Err False |
||
138 | If Not iRetval Begin |
||
139 | Error 500 csOsVersionNumberCouldNotRetrieved |
||
140 | Procedure_Return |
||
141 | End |
||
142 | GetBuff From sOSVersionInfo At _OSVERSIONINFO.dwMajorVersion To iRetval |
||
143 | Set piMajorVersion To iRetval |
||
144 | GetBuff From sOSVersionInfo At _OSVERSIONINFO.dwMinorVersion To iRetval |
||
145 | Set piMinorVersion To iRetval |
||
146 | GetBuff From sOSVersionInfo At _OSVERSIONINFO.dwPlatformID To iRetval |
||
147 | Set piPlatFormId To iRetval |
||
148 | GetBuff_String From sOSVersionInfo At _OSVERSIONINFO.szCSDVersion To sCSDVersion |
||
149 | Move (Cstring(sCSDVersion)) To sCSDVersion |
||
150 | Set psCSDVersion To (Trim(sCSDVersion)) |
||
151 | End_Procedure // DoGetVersionInfo |
||
152 | |||
153 | Procedure DoGetVersionInfoEx |
||
154 | Integer iRetval |
||
155 | String sOSVersionInfoEx sCSDVersion |
||
156 | Pointer pOSVersionInfoEx |
||
157 | |||
158 | FillType _OSVERSIONINFOEX With 0 To sOSVersionInfoEX |
||
159 | Put _OSVERSIONINFOEX_Size To sOSVersionInfoEx At _OSVERSIONINFOEX.dwOSVersionInfoSize |
||
160 | GetAddress Of sOSVersionInfoEX To pOSVersionInfoEX |
||
161 | Move (GetVersionEx(pOSVersionInfoEx)) To iRetval |
||
162 | Indicate Err False |
||
163 | If Not iRetval Begin |
||
164 | Error 500 csOsVersionNumberCouldNotRetrieved |
||
165 | Procedure_Return |
||
166 | End |
||
167 | |||
168 | GetBuff From sOSVersionInfoEx At _OSVERSIONINFOEX.dwMajorVersion To iRetval |
||
169 | Set piMajorVersion To iRetval |
||
170 | |||
171 | GetBuff From sOSVersionInfoEx At _OSVERSIONINFOEX.dwMinorVersion To iRetval |
||
172 | Set piMinorVersion To iRetval |
||
173 | |||
174 | GetBuff From sOSVersionInfoEx At _OSVERSIONINFOEX.dwBuildNumber To iRetval |
||
175 | Set piBuildNumber To iRetval |
||
176 | |||
177 | GetBuff From sOSVersionInfoEx At _OSVERSIONINFOEX.dwPlatformID To iRetval |
||
178 | Set piPlatFormId To iRetval |
||
179 | |||
180 | GetBuff_String From sOSVersionInfoEx At _OSVERSIONINFOEX.szCSDVersion To sCSDVersion |
||
181 | Move (Cstring(sCSDVersion)) To sCSDVersion |
||
182 | Set psCSDVersion To (Trim(sCSDVersion)) |
||
183 | |||
184 | GetBuff From sOSVersionInfoEx At _OSVERSIONINFOEX.wServicePackMajor To iRetval |
||
185 | Set piServicePackMajor To iRetval |
||
186 | |||
187 | GetBuff From sOSVersionInfoEx At _OSVERSIONINFOEX.wServicePackMinor To iRetval |
||
188 | Set piServicePackMinor To iRetval |
||
189 | |||
190 | GetBuff From sOSVersionInfoEx At _OSVERSIONINFOEX.wSuiteMask To iRetval |
||
191 | Set piSuiteMask To iRetval |
||
192 | |||
193 | GetBuff From sOSVersionInfoEx At _OSVERSIONINFOEX.wProductType To iRetval |
||
194 | Set piProductType To iRetval |
||
195 | |||
196 | End_Procedure // DoGetVersionInfoEx |
||
197 | |||
198 | // |
||
199 | // Determines processor architecture and windows editions |
||
200 | // |
||
201 | Procedure RetrieveOSEdition Integer iMajorVersion Integer iMinorVersion Integer iSuiteMask |
||
202 | Handle hoSystemInfo |
||
203 | Integer iProcessorArchitecture |
||
204 | String sEdition |
||
205 | |||
206 | |||
207 | Move PROCESSOR_ARCHITECTURE_UNKNOWN To iProcessorArchitecture |
||
208 | |||
209 | // Min version is XP |
||
210 | Get Create U_cSystemInfo To hoSystemInfo |
||
211 | If (hoSystemInfo) Begin |
||
212 | Get piProcessorArchitecture Of hoSystemInfo To iProcessorArchitecture |
||
213 | If (iProcessorArchitecture=PROCESSOR_ARCHITECTURE_AMD64) Begin |
||
214 | Set pbX64 To True |
||
215 | End |
||
216 | End |
||
217 | |||
218 | If (GetSystemMetrics(SM_MEDIACENTER)<>0) Begin |
||
219 | Move CS_OS_MCE To sEdition |
||
220 | End |
||
221 | If (GetSystemMetrics(SM_STARTER)<>0) Begin |
||
222 | Move CS_OS_STARTER To sEdition |
||
223 | End |
||
224 | If (GetSystemMetrics(SM_TABLETPC)<>0) Begin |
||
225 | Move CS_OS_TABLETPC To sEdition |
||
226 | End |
||
227 | |||
228 | Case Begin |
||
229 | Case (iSuiteMask Iand Ver_Suite_Personal) |
||
230 | Move CS_OS_HOME To sEdition |
||
231 | Set pbWindowsHome To True |
||
232 | Case Break |
||
233 | Case (iSuiteMask Iand Ver_Suite_EmbeddedNT) |
||
234 | Move CS_OS_EMBEDDED To sEdition |
||
235 | Case Break |
||
236 | Case (iSuiteMask Iand Ver_Suite_Blade) |
||
237 | Move CS_OS_WEB To sEdition |
||
238 | Case Break |
||
239 | Case (iSuiteMask Iand Ver_Suite_Datacenter) |
||
240 | Move CS_OS_DATACENTER To sEdition |
||
241 | Case Break |
||
242 | Case (iSuiteMask Iand Ver_Suite_Enterprise) |
||
243 | Move CS_OS_ENTERPRISE To sEdition |
||
244 | Case Break |
||
245 | Case End |
||
246 | |||
247 | If (sEdition<>"") Begin |
||
248 | // Microsoft had the habit of adding "Edition" behind its edition identifier string in the past |
||
249 | If (iMajorVersion=5 and iMinorVersion>=1) Move (sEdition*CS_OS_EDITION) To sEdition |
||
250 | End |
||
251 | Set psEdition To sEdition |
||
252 | End_Procedure // RetrieveOSEdition |
||
253 | |||
254 | // |
||
255 | // Determine the psSuite string and try to find out features such as if you are running in an |
||
256 | // remote Desktop session, or if the user has administrator rights |
||
257 | // |
||
258 | Procedure RetrieveOSFeatures Integer iMajorVersion Integer iMinorVersion |
||
259 | String sSuite |
||
260 | |||
261 | Move "" To sSuite |
||
262 | If (GetSystemMetrics(SM_REMOTESESSION)<>0) Begin |
||
263 | Move (sSuite+CS_OS_REMOTESESSION) To sSuite |
||
264 | Set pbRemoteDesktop To True |
||
265 | End |
||
266 | If (iMajorVersion>5 or (iMajorVersion>=5 and iMinorVersion>=1)) Begin |
||
267 | // Check only win2000 and up |
||
268 | If (IsAdministrator()) Begin |
||
269 | If (sSuite<>"") Move (sSuite+", ") To sSuite |
||
270 | Move (sSuite+CS_OS_ISADMINISTRATOR) To sSuite |
||
271 | Set pbAdminRights To True |
||
272 | End |
||
273 | End |
||
274 | Set psSuite To sSuite |
||
275 | End_Procedure // RetrieveOSFeatures |
||
276 | |||
277 | // |
||
278 | // This sets the psOsVersion and peOSVersion properties based on what has been found. |
||
279 | // The psOSversion should not be used to identify the base OS, use peOSVersion for that. |
||
280 | // |
||
281 | Procedure RetrieveOSVersion |
||
282 | Integer iMajorVersion |
||
283 | Integer iMinorVersion |
||
284 | Integer iBuildNumber |
||
285 | Integer iPlatFormId |
||
286 | String sCSDVersion |
||
287 | String sOSVersion |
||
288 | Integer iServicePackMajor |
||
289 | Integer iServicePackMinor |
||
290 | Integer iSuiteMask |
||
291 | Integer iProductType |
||
292 | Boolean bServerR2 |
||
293 | |||
294 | Move False To bServerR2 |
||
295 | |||
296 | Get piMajorVersion To iMajorVersion |
||
297 | Get piMinorVersion To iMinorVersion |
||
298 | Get piBuildNumber To iBuildNumber |
||
299 | Get piPlatFormId To iPlatFormId |
||
300 | Get psCSDVersion To sCSDVersion |
||
301 | Get piServicePackMajor To iServicePackMajor |
||
302 | Get piServicePackMinor To iServicePackMinor |
||
303 | Get piSuiteMask To iSuiteMask |
||
304 | Get piProductType To iProductType |
||
305 | |||
306 | If (iMajorVersion>5 or (iMajorVersion>=5 and iMinorVersion>=1)) Begin |
||
307 | // Set psEdition and check x64 capabilities |
||
308 | Send RetrieveOSEdition iMajorVersion iMinorVersion iSuiteMask |
||
309 | If (GetSystemMetrics(SM_SERVERR2)<>0) Begin |
||
310 | Move True To bServerR2 |
||
311 | End |
||
312 | End |
||
313 | If (iMajorVersion>=5) Begin |
||
314 | Send RetrieveOSFeatures iMajorVersion iMinorVersion |
||
315 | End |
||
316 | |||
317 | Case Begin |
||
318 | Case (iMajorVersion = 3) |
||
319 | Set psOSVersion To CS_OSVERSION_NT35 |
||
320 | Set peOSVersion To CE_OSVERSION_NT35 |
||
321 | Case Break |
||
322 | |||
323 | Case (iMajorVersion = 4) // Windows 9X Series and Win NT 40 |
||
324 | If (iPlatFormId = CP_VER_PLATFORM_WIN32_WINDOWS) Begin // Then Windows 95 or 98... |
||
325 | Case Begin |
||
326 | Case (iMinorVersion = 0) |
||
327 | Set psOSVersion To CS_OSVERSION_WIN95 |
||
328 | Set peOSVersion To CE_OSVERSION_WIN95 |
||
329 | Case Break |
||
330 | Case (iMinorVersion = 10) |
||
331 | Set psOSVersion To CS_OSVERSION_WIN98 |
||
332 | Set peOSVersion To CE_OSVERSION_WIN98 |
||
333 | Case Break |
||
334 | Case (iMinorVersion = 90) |
||
335 | Set psOSVersion To CS_OSVERSION_WINME |
||
336 | Set peOSVersion To CE_OSVERSION_WINME |
||
337 | Set pbWindowsHome To True |
||
338 | Case Break |
||
339 | Case End |
||
340 | End |
||
341 | Else Begin |
||
342 | Case Begin |
||
343 | Case (iProductType = VER_NT_WORKSTATION) |
||
344 | Set psOSVersion To CS_OSVERSION_NT4WKS |
||
345 | Set peOSVersion To CE_OSVERSION_NT4WKS |
||
346 | Case Break |
||
347 | Case (iProductType = VER_NT_DOMAIN_CONTROLLER) |
||
348 | Set psOSVersion To CS_OSVERSION_NT4SRV |
||
349 | Set peOSVersion To CE_OSVERSION_NT4SRV |
||
350 | Set pbNTServer To True |
||
351 | Case Break |
||
352 | Case End |
||
353 | End |
||
354 | Case Break |
||
355 | |||
356 | Case (iMajorVersion = 5) // Windows NT2k Series |
||
357 | Case Begin |
||
358 | Case (iMinorVersion = 0) // Windows 2000 |
||
359 | If (iProductType = VER_NT_WORKSTATION) Begin |
||
360 | Set psOSVersion To CS_OSVERSION_W2K |
||
361 | Set peOSVersion To CE_OSVERSION_W2K |
||
362 | End |
||
363 | Else Begin |
||
364 | Set psOSVersion To CS_OSVERSION_W2KSRV |
||
365 | Set peOSVersion To CE_OSVERSION_W2KSRV |
||
366 | Set pbNTServer To True |
||
367 | End |
||
368 | Case Break |
||
369 | |||
370 | Case (iMinorVersion = 1) // XP (and NOT 2003 server) |
||
371 | Case Begin |
||
372 | Case (iSuiteMask Iand Ver_Suite_Personal) |
||
373 | Set psOSVersion To CS_OSVERSION_WXP |
||
374 | Set peOSVersion To CE_OSVERSION_WXP |
||
375 | Set pbWindowsHome To True |
||
376 | Case Break |
||
377 | |||
378 | Case (iProductType = VER_NT_WORKSTATION) |
||
379 | If (psEdition(Self)="") Move CS_OSVERSION_WXPPRO To sOSVersion |
||
380 | Else Move CS_OSVERSION_WXP To sOSVersion |
||
381 | Set psOSVersion To sOSVersion |
||
382 | Set peOSVersion To CE_OSVERSION_WXP |
||
383 | Case Break |
||
384 | |||
385 | Case End |
||
386 | Case Break |
||
387 | |||
388 | Case (iMinorVersion = 2) |
||
389 | |||
390 | Case Begin |
||
391 | // WXP x64 |
||
392 | // (OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION) && (SYSTEM_INFO.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) |
||
393 | Case (iProductType = VER_NT_WORKSTATION and pbX64(Self)=True) |
||
394 | Set psOSversion To CS_OSVERSION_WXPX64 |
||
395 | Set peOSVersion To CE_OSVERSION_WXP |
||
396 | Case Break |
||
397 | |||
398 | Case (bServerR2=false) |
||
399 | Set psOSVersion To CS_OSVERSION_2K3 |
||
400 | Set peOSVersion To CE_OSVERSION_2K3 |
||
401 | Set pbNTServer To True |
||
402 | Case Break |
||
403 | Case (iSuiteMask Iand VER_SUITE_WH_SERVER) |
||
404 | Set psOSVersion To CS_OSVERSION_HMESRV |
||
405 | Set peOSVersion To CE_OSVERSION_2K3 |
||
406 | Set pbNTServer To True |
||
407 | Case Break |
||
408 | Case (bServerR2=True) |
||
409 | Set psOSVersion To CS_OSVERSION_2K3R2 |
||
410 | Set peOSVersion To CE_OSVERSION_2K3R2 |
||
411 | Set pbNTServer To True |
||
412 | Case Break |
||
413 | Case End |
||
414 | Case Break |
||
415 | Case End |
||
416 | Case Break |
||
417 | |||
418 | Case (iMajorVersion = 6) // Windows Vista / Home Server Series / Windows 7 & Windows 8 |
||
419 | Case Begin |
||
420 | Case (iMinorVersion = 0) // Windows Vista |
||
421 | Case Begin |
||
422 | Case (iSuiteMask Iand Ver_Suite_Personal) |
||
423 | Set psOSVersion To CS_OSVERSION_VISTA |
||
424 | Set peOSVersion To CE_OSVERSION_VISTA |
||
425 | Set pbWindowsHome To True |
||
426 | Case Break |
||
427 | |||
428 | Case (iProductType = VER_NT_WORKSTATION) |
||
429 | Set psOSVersion To CS_OSVERSION_VISTA |
||
430 | Set peOSVersion To CE_OSVERSION_VISTA |
||
431 | Case Break |
||
432 | Case (iProductType <> VER_NT_WORKSTATION) |
||
433 | Set psOSVersion to CS_OSVERSION_2K8 |
||
434 | Set peOSVersion to CE_OSVERSION_2K8 |
||
435 | Set pbNTServer To True |
||
436 | Case Break |
||
437 | Case End |
||
438 | Case Break |
||
439 | Case (iMinorVersion = 1) // Windows 7 |
||
440 | Case Begin |
||
441 | Case (iProductType = VER_NT_WORKSTATION) |
||
442 | Set psOSVersion To CS_OSVERSION_W7 |
||
443 | Set peOSVersion To CE_OSVERSION_W7 |
||
444 | Case Break |
||
445 | Case (iProductType <> VER_NT_WORKSTATION) |
||
446 | Set psOSVersion to CS_OSVERSION_2K8R2 |
||
447 | Set peOSVersion to CE_OSVERSION_2K8R2 |
||
448 | Set pbNTServer To True |
||
449 | Case Break |
||
450 | Case End |
||
451 | Case Break |
||
452 | |||
453 | Case (iMinorVersion = 2) // Windows 8 and Windows 2012 |
||
454 | Case Begin |
||
455 | Case (iProductType = VER_NT_WORKSTATION) |
||
456 | Set psOSVersion To CS_OSVERSION_W8 |
||
457 | Set peOSVersion To CE_OSVERSION_W8 |
||
458 | Case Break |
||
459 | Case (iProductType <> VER_NT_WORKSTATION) |
||
460 | Set psOSVersion to CS_OSVERSION_2K12 |
||
461 | Set peOSVersion to CE_OSVERSION_2K12 |
||
462 | Set pbNTServer To True |
||
463 | Case Break |
||
464 | Case End |
||
465 | Case Break |
||
466 | |||
467 | Case End |
||
468 | Case Break |
||
469 | |||
470 | Case End |
||
471 | End_Procedure // RetrieveOSVersion |
||
472 | |||
473 | // |
||
474 | // Returns the full OS version name including service pack level as a string |
||
475 | // |
||
476 | // If the version is unknown to the package, it will list the major and |
||
477 | // minor version appended the string returned in the format " (major.minor)" |
||
478 | // |
||
479 | Function OSVersion Returns String |
||
480 | Integer iServicePack |
||
481 | Integer iBuildNumber |
||
482 | Integer iMajor |
||
483 | Integer iMinor |
||
484 | String sOSVersion |
||
485 | String sSuite |
||
486 | String sEdition |
||
487 | String sCSDVersion |
||
488 | |||
489 | Get psOSVersion To sOSVersion |
||
490 | |||
491 | If (sOSVersion=CS_OSVERSION_UNKNOWN) Begin |
||
492 | Get piMajorVersion To iMajor |
||
493 | Get piMinorVersion To iMinor |
||
494 | Move (sOSVersion+" ("+trim(iMajor)+"."+trim(iMinor)+")") To sOSVersion |
||
495 | End |
||
496 | Else Begin |
||
497 | Get psEdition To sEdition |
||
498 | If (sEdition<>"") Begin |
||
499 | Move (sOSVersion*sEdition) To sOSVersion |
||
500 | End |
||
501 | Get piBuildNumber To iBuildNumber |
||
502 | If (iBuildNumber<>0) Begin |
||
503 | Move (sOSVersion+" Build "+trim(iBuildNumber)+" ") To sOSVersion |
||
504 | End |
||
505 | Get piServicePackMajor To iServicePack |
||
506 | If (iServicePack>0) Begin |
||
507 | Get psCSDVersion To sCSDVersion |
||
508 | Move (sOSVersion+sCSDVersion) To sOSVersion |
||
509 | End |
||
510 | End |
||
511 | |||
512 | If (pbX64(Self)) Begin |
||
513 | Move (sOSVersion * "x64") To sOSVersion |
||
514 | End |
||
515 | Get psSuite To sSuite |
||
516 | If (sSuite<>"") Begin |
||
517 | Move (sOSVersion*"("+sSuite+")") To sOSVersion |
||
518 | End |
||
519 | |||
520 | Function_Return sOSVersion |
||
521 | End_Function // OSVersion |
||
522 | |||
523 | |||
524 | |||
525 | // This is the main procedure that checks which Windows version |
||
526 | // is running and calls the appropiate procedure above. |
||
527 | // SETS PUBLIC OS PROPERTIES |
||
528 | // Gets called by End_Construct_Object below. |
||
529 | Procedure DoCheckWindowsVersion |
||
530 | |||
531 | Indicate Err False |
||
532 | Send DoGetVersionInfo |
||
533 | If ((piMajorVersion (Self)) > 4) Begin |
||
534 | Indicate Err False |
||
535 | Send DoGetVersionInfoEx |
||
536 | End |
||
537 | |||
538 | If Not (Err) Begin |
||
539 | Send RetrieveOSVersion |
||
540 | End |
||
541 | |||
542 | End_Procedure // DoCheckWindowsVersion |
||
543 | |||
544 | |||
545 | |||
546 | // Automatically sets all class properties upon creation. |
||
547 | Procedure End_Construct_Object |
||
548 | Forward Send End_Construct_Object |
||
549 | Send DoCheckWindowsVersion |
||
550 | End_Procedure // End_Construct_Object |
||
551 | |||
552 | End_Class // cOSVersionInfo |