给你个我用的例子:
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
|
; 脚本用 Inno Setup 脚本向导生成。 ; 查阅文档获取创建 INNO SETUP 脚本文件详细资料! [Setup] AppName=Common downloader AppVerName=Common downloader DefaultDirName= {pf} \XXX\Common downloader DefaultGroupName=XXX\Common downloader DisableProgramGroupPage=yes OutputDir= .\Setup OutputBaseFilename=Common downloader setup V1 .0.0 Compression=lzma SolidCompression=yes VersionInfoCompany=XXX VersionInfoVersion= 1.0.0 [Languages] Name: "Chinese"; MessagesFile: "compiler:Languages\Chinese . isl" Name: "English"; MessagesFile: "compiler:Languages\English . isl" [Tasks] Name: "desktopicon"; Description: " {cm:CreateDesktopIcon} "; GroupDescription: " {cm:AdditionalIcons} "; Flags: dontinheritcheck [Files] Source: "CMDL . exe"; DestName: "Common downloader . exe"; DestDir: " {app} "; Flags: ignoreversion Source: "DL . dll"; DestDir: " {app} "; Flags: ignoreversion Source: "DM . dll"; DestDir: " {app} "; Flags: ignoreversion Source: "config . ini"; DestDir: " {app} "; Flags: ignoreversion Source: "App\*"; DestDir: " {app} \\App"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "Boot\*"; DestDir: " {app} \\Boot"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "Resource_cn\*"; DestDir: " {app} \Resource"; Languages: Chinese; Flags: ignoreversion recursesubdirs createallsubdirs Source: "Resource_en\*"; DestDir: " {app} \Resource"; Languages: English; Flags: ignoreversion recursesubdirs createallsubdirs ; 注意: 不要在任何共享系统文件中使用“Flags: ignoreversion” [Icons] Name: " {group} \Common downloader"; Filename: " {app} \Common downloader . exe" Name: " {group} \ {cm:UninstallProgram,Common downloader} "; Filename: " {uninstallexe} " Name: " {userdesktop} \Common downloader"; Filename: " {app} \Common downloader . exe"; Tasks: desktopicon [Run] Filename: " {app} \Common downloader . exe"; Description: " {cm:LaunchProgram,Common downloader} "; Flags: nowait postinstall skipifsilent [Registry] Root: HKLM; Subkey: "Software\XXX"; Flags: createvalueifdoesntexist Root: HKLM; Subkey: "Software\XXX\Common downloader"; Flags: uninsdeletekeyifempty Root: HKLM; Subkey: "Software\XXX\Common downloader"; ValueType: string ; ValueName: "Path"; ValueData: " {app} " Root: HKLM; Subkey: "Software\XXX\Common downloader"; ValueType: string ; ValueName: "Version"; ValueData: "V1 .0.0 " Root: HKLM; Subkey: "Software\XXX\Common downloader"; ValueType: dword; ValueName: "VersionNum"; ValueData: " 100 " Root: HKLM; Subkey: "Software\XXX\Common downloader"; ValueType: string ; ValueName: "Release Date"; ValueData: " 2008 / 09 / 29 " [Code] function InitializeSetup(): Boolean ; var Version: string ; strPath: string ; ResultCode: Integer ; begin Result:= TRUE ; //read the version if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\XXX\Common downloader' , 'Version' , Version) then begin // Successfully read the value Version := Format( 'Exist the version %s,whether uninstall it?' ,[Version]); if MsgBox(Version,mbConfirmation,MB_YESNO) = IDYES then begin //read the path if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\XXX\Common downloader' , 'Path' , strPath) then begin // Successfully read the value strPath:= strPath + '\unins000.exe' ; Exec(ExpandConstant(strPath), '' , '' , SW_SHOW, ewWaitUntilTerminated, ResultCode); end ; end else Result:= FALSE ; end ; end ; |
这个例子可以在安装之前卸载以前的版本,并提示你卸载之前的版本信息。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
2017-10-18 国内大公司的开源项目一览表
2012-10-18 使用.NET Reflector单步调试编译好的程序集
2012-10-18 IE8 调试ocx 无法进入断点 .