
摘要:由于现在 Windows 版本越来越多,而有些开发的程序对旧版本已经不支持。作为一个开发人员在用户安装相关软件的时候肯定会考虑到有些系统已经不适用于较旧的 Windows 版本,而今天大眼仔旭给大家分享的就是通过 Inno Setup 在编译安装包的时候加入 Windows 系统版本检测代码就可以有效的提醒用户当前使用…
由于现在 Windows 版本越来越多,而有些开发的程序对旧版本已经不支持。作为一个开发人员在用户安装相关软件的时候肯定会考虑到有些系统已经不适用于较旧的 Windows 版本,而今天大眼仔旭给大家分享的就是通过 Inno Setup 在编译安装包的时候加入 Windows 系统版本检测代码就可以有效的提醒用户当前使用的 Windows 操作系统是否适用。
Inno Setup 脚本示例中的代码请大家根据实际情况来进行选择合并使用。
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 ; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
#define MyAppName "我的程序"
#define MyAppVersion "1.5"
#define MyAppPublisher "我的公司"
#define MyAppURL "http://www.dayanzai.me/"
#define MyAppExeName "MyProg.exe"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{D5A23F5E-6AE2-40E9-88A5-5D6579687632}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "C:\MyProgramFiles\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
function InitializeSetup: Boolean;
var
ProductName:String;//系统名称
EditionID:String; //系统版本
CSDVersion:String; //系统Service Pack 版本
Info:String;//支持系统提示
S: String; //调试信息
begin
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductName', ProductName);
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'EditionID', EditionID);
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'CSDVersion', CSDVersion);
S:='ProductName:'+ProductName+#13#10;
S:=S+'EditionID:'+EditionID+#13#10;
S:=S+'CSDVersion:'+CSDVersion+#13#10;
Info:= '当前系统不符合软件安装要求,请更换操作系统或使用其他服务器。 '+#13#10;
Info:=Info+'支持系统列表:'+#13#10;
Info:=Info+'Windwos 7:'+#13#10;
Info:=Info+'Ultimate/Enterprise/Professional 并且要求安装 Service Pack 1'+#13#10;
Info:=Info+'Windows 10:'+#13#10;
Info:=Info+'Enterprise/Professional'+#13#10;
Info:=Info+'Windows Server 2008 R2:'+#13#10;
Info:=Info+'Standard/Enterprise 并且要求安装 Service Pack 1'+#13#10;
Info:=Info+'Windows Server 2012 R2:'+#13#10;
Info:=Info+'Standard/Enterprise'+#13#10;
//SuppressibleMsgBox(Info, mbCriticalError, MB_OK, MB_OK);
//ProductName:=Lowercase(ProductName);
//Windows 7 系统检测
if (Pos('Windows 7', ProductName) > 0)then
begin
if((Pos('Ultimate', EditionID) > 0) or (Pos('Enterprise', EditionID) > 0) or (Pos('Professional', EditionID) > 0)) and (Pos('Service Pack 1',CSDVersion)> 0) then
begin
//MsgBox(S,mbInformation,MB_OK); //调试输出,发布请注释掉
Result:=true;
Exit;
end else
begin
SuppressibleMsgBox(Info, mbCriticalError, MB_OK, MB_OK);
Result:=false;
Exit;
end;
end;
//Windows 10 系统检测
if (Pos('Windows 10', ProductName) > 0)then
begin
if((Pos('Enterprise', EditionID) > 0) or (Pos('Professional', EditionID)> 0))then
begin
//MsgBox(S,mbInformation,MB_OK); //调试输出,发布请注释掉
Result:=true;
Exit;
end else
begin
SuppressibleMsgBox(Info,mbCriticalError, MB_OK, MB_OK);
Result:=false;
Exit;
end;
end;
//Windows Server 2008 R2 sp1 系统检测
if (Pos('Windows Server 2008 R2', ProductName) > 0)then
begin
if((Pos('ServerEnterprise', EditionID)> 0) or (Pos('ServerStandard', EditionID)> 0)) and (Pos('Service Pack 1', CSDVersion)> 0)then
begin
//MsgBox(S,mbInformation,MB_OK); //调试输出,发布请注释掉
Result:=true;
Exit;
end else
begin
SuppressibleMsgBox(Info, mbCriticalError, MB_OK, MB_OK);
Result:=false;
Exit;
end;
end;
//Windows Server 2012 R2 系统检测
if (Pos('Windows Server 2012 R2', ProductName) > 0)then
begin
if(Pos('ServerEnterprise', EditionID)> 0) or (Pos('ServerStandard', EditionID)> 0)then
begin
//MsgBox(S,mbInformation,MB_OK); //调试输出,发布请注释掉
Result:=true;
Exit;
end
else
begin
SuppressibleMsgBox(Info, mbCriticalError, MB_OK, MB_OK);
Result:=false;
Exit;
end;
end;
SuppressibleMsgBox(Info, mbCriticalError, MB_OK, MB_OK);
Result := false;
end;
如果您不会整合脚本使用,那么建议您可以先尝试多了解并学习下 Inno Setup,然后再尝试制作一些相对于高级进阶的内容。
声明:大眼仔旭 | 本文采用知识共享署名 4.0 国际许可协议[BY-NC-SA]进行授权
文章名称:《Inno Setup 检测 Windows 系统版本解决方案》
文章固定链接:http://www.dayanzai.me/inno-setup-version.html
本站资源仅供个人学习交流,请于下载后 24 小时内删除,不允许用于商业用途,否则法律问题自行承担。
文章名称:《Inno Setup 检测 Windows 系统版本解决方案》
文章固定链接:http://www.dayanzai.me/inno-setup-version.html
本站资源仅供个人学习交流,请于下载后 24 小时内删除,不允许用于商业用途,否则法律问题自行承担。
转载声明
猜你喜欢
相关推荐
全部评论: (0条)
^_^ 暂无评论!
发表评论
最新标签
Adobe
Ashampoo
Autodesk
CyberLink
GitHub
Inno Setup 技巧
Inno Setup 教程
JetBrains
Microsoft
Office
PDF 编辑器
PDF 阅读器
Win10 技巧
Windows 10
Windows 10 技巧
Wise Soft
下载工具
代码编辑器
免费商用字体
免费字体
免费软件
办公软件
图像处理工具
图像浏览器
安卓软件
屏幕录像
屏幕录像工具
屏幕录像软件
开源软件
思维导图
截图工具
数据恢复
数据恢复工具
文本编辑器
格式转换工具
桌面录像
游戏录像
系统优化工具
系统增强
系统增强工具
编程开发
视频播放器
视频转换器
视频转换工具
音乐播放器