1 /******************************************************************************
2 *
3 * Copyright (C) 2008, Gentee, Inc. All rights reserved.
4 * This file is part of the Perfect Automation project - http://www.perfectautomation.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE PERFECT AUTOMATION LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * Author: Alexey Krivonogov ( gentee )
11 *
12 ******************************************************************************/
13
14 type OSVERSIONINFO
15 {
16 uint dwOSVersionInfoSize
17 uint dwMajorVersion
18 uint dwMinorVersion
19 uint dwBuildNumber
20 uint dwPlatformId
21 reserved szCSDVersion[ 128 ]
22 }
23
24 type winver
25 {
26 uint windows
27 uint major
28 uint minor
29 uint platform
30 uint build
31 str csd
32 }
33
34 define
35 { // Values for winver.windows
36 WIN_UNKNOWN = 0
37 WIN_95
38 WIN_98
39 WIN_ME
40 WIN_NT
41 WIN_2000
42 WIN_XP
43 WIN_2003
44 WIN_VISTA
45 WIN_7
46 }
47
48 import "kernel32.dll"
49 {
50 uint GetVersionExA( OSVERSIONINFO ) -> GetVersionEx
51 }
52
53 func uint winversion( winver result )
54 {
55 OSVERSIONINFO osv
56
57 osv.dwOSVersionInfoSize = sizeof( OSVERSIONINFO )
58 if GetVersionEx( osv )
59 {
60 result.platform = osv.dwPlatformId
61 result.major = osv.dwMajorVersion
62 result.minor = osv.dwMinorVersion
63 result.build = ?( osv.dwPlatformId == 2, osv.dwBuildNumber,
64 osv.dwBuildNumber & 0xFFFF )
65 result.csd.copy( &osv.szCSDVersion )
66 if osv.dwPlatformId == 1
67 {
68 if osv.dwMajorVersion == 4
69 {
70 result.windows = ?( osv.dwMinorVersion >= 10,
71 ? ( osv.dwMinorVersion >= 90, $WIN_ME, $WIN_98 ), $WIN_95 )
72 }
73 }
74 elif osv.dwPlatformId == 2
75 {
76 switch osv.dwMajorVersion
77 {
78 case 4 : result.windows = $WIN_NT
79 case 6
80 {
81 result.windows = ?( !osv.dwMinorVersion, $WIN_VISTA, $WIN_7 )
82 }
83 default
84 {
85 switch osv.dwMinorVersion
86 {
87 case 0 : result.windows = $WIN_2000
88 case 1 : result.windows = $WIN_XP
89 case 2 : result.windows = $WIN_2003
90 }
91 }
92 }
93 }
94 return 1
95 }
96 return 0
97 }
Редактировать