VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/winver.nsh@ 71731

最後變更 在這個檔案從71731是 54006,由 vboxsync 提交於 10 年 前

Windows additions: OS version check fixes

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 2.2 KB
 
1; GetWindowsVersion
2;
3; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/
4; Updated by Joost Verburg
5;
6; Returns on top of stack
7;
8; Windows Version (95, 98, ME, NT x.x, 2000, XP, 2003, Vista)
9; or
10; '' (Unknown Windows Version)
11;
12; Usage:
13; Call GetWindowsVersion
14; Pop $R0
15; ; at this point $R0 is "NT 4.0" or whatnot
16
17!macro GetWindowsVersion un
18Function ${un}GetWindowsVersion
19
20 Push $R0
21 Push $R1
22
23 ClearErrors
24
25 ReadRegStr $R0 HKLM \
26 "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
27
28 IfErrors 0 lbl_winnt
29
30 ; we are not NT
31 ReadRegStr $R0 HKLM \
32 "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
33
34 StrCpy $R1 $R0 1
35 StrCmp $R1 '4' 0 lbl_error
36
37 StrCpy $R1 $R0 3
38
39 StrCmp $R1 '4.0' lbl_win32_95
40 StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98
41
42 lbl_win32_95:
43 StrCpy $R0 '95'
44 Goto lbl_done
45
46 lbl_win32_98:
47 StrCpy $R0 '98'
48 Goto lbl_done
49
50 lbl_win32_ME:
51 StrCpy $R0 'ME'
52 Goto lbl_done
53
54 lbl_winnt:
55
56 StrCpy $R1 $R0 1
57
58 StrCmp $R1 '3' lbl_winnt_x
59 StrCmp $R1 '4' lbl_winnt_x
60
61 StrCpy $R1 $R0 3
62
63 StrCmp $R1 '5.0' lbl_winnt_2000
64 StrCmp $R1 '5.1' lbl_winnt_XP
65 StrCmp $R1 '5.2' lbl_winnt_2003
66 StrCmp $R1 '6.0' lbl_winnt_vista
67 StrCmp $R1 '6.1' lbl_winnt_7
68 StrCmp $R1 '6.2' lbl_winnt_8
69
70 ; Windows 10 preview 9926 has CurrentVersion == 6.3
71 ; Check Windows 10 registry values
72 ReadRegDWORD $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentMajorVersionNumber"
73 ${If} $R0 == "10"
74 Goto lbl_winnt_10
75 ${EndIf}
76
77 StrCmp $R1 '6.3' lbl_winnt_8_1
78 StrCmp $R1 '6.4' lbl_winnt_10 lbl_error
79
80 lbl_winnt_x:
81 StrCpy $R0 "NT $R0" 6
82 Goto lbl_done
83
84 lbl_winnt_2000:
85 Strcpy $R0 '2000'
86 Goto lbl_done
87
88 lbl_winnt_XP:
89 Strcpy $R0 'XP'
90 Goto lbl_done
91
92 lbl_winnt_2003:
93 Strcpy $R0 '2003'
94 Goto lbl_done
95
96 lbl_winnt_vista:
97 Strcpy $R0 'Vista'
98 Goto lbl_done
99
100 lbl_winnt_7:
101 Strcpy $R0 '7'
102 Goto lbl_done
103
104 lbl_winnt_8:
105 Strcpy $R0 '8'
106 Goto lbl_done
107
108 lbl_winnt_8_1: ; Also includes Windows Server 2012 R2
109 Strcpy $R0 '8_1'
110 Goto lbl_done
111
112 lbl_winnt_10:
113 Strcpy $R0 '10'
114 Goto lbl_done
115
116 lbl_error:
117 Strcpy $R0 ''
118 lbl_done:
119
120 Pop $R1
121 Exch $R0
122
123FunctionEnd
124!macroend
125!insertmacro GetWindowsVersion ""
126!insertmacro GetWindowsVersion "un."
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette