inno setup 之Deltree 用法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了inno setup 之Deltree 用法相关的知识,希望对你有一定的参考价值。
网上很多人说用这个函数可以删除整个文件夹,包括里面的文件和子目录,但是我经过测试,发现如果是空目录的话就可以删除,删除空目录也可以用Removedir,如果文件夹里面还有文件的话就无法删除。我在inno setup的帮助文档查看DelTree时,注释讲这个函数将删除重新解析指定的目录,但它不递归删除它内部的文件/目录。卸载时只会卸载安装的东西,如果是后来自动生成的文件和目录该怎么删除,假设不使用[uninstallDelete]字段,请问有哪位高手知道这个问题怎么解决?请高手多多指教!
// 删除 C:\Test 中的所有文件和目录// 但保留它本身目录
DelTree('C:\Test\*', False, True, True);
帮助文档里面有的。我测试过是可用的。 参考技术A 哇塞,第一次接触Deltree,学习了,哈哈 参考技术B ??追问
你知道这个问题怎么解决吗?
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
|
; 脚本用 Inno Setup 脚本向导生成。 ; 查阅文档获取创建 INNO SETUP 脚本文件详细资料! [Setup] AppName=Common downloader AppVerName=Common downloader DefaultDirName= {pf} XXXCommon downloader DefaultGroupName=XXXCommon 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:LanguagesChinese . isl" Name: "English"; MessagesFile: "compiler:LanguagesEnglish . 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: "SoftwareXXX"; Flags: createvalueifdoesntexist Root: HKLM; Subkey: "SoftwareXXXCommon downloader"; Flags: uninsdeletekeyifempty Root: HKLM; Subkey: "SoftwareXXXCommon downloader"; ValueType: string ; ValueName: "Path"; ValueData: " {app} " Root: HKLM; Subkey: "SoftwareXXXCommon downloader"; ValueType: string ; ValueName: "Version"; ValueData: "V1 .0.0 " Root: HKLM; Subkey: "SoftwareXXXCommon downloader"; ValueType: dword; ValueName: "VersionNum"; ValueData: " 100 " Root: HKLM; Subkey: "SoftwareXXXCommon 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, ‘SoftwareXXXCommon 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, ‘SoftwareXXXCommon 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 ; |
这个例子可以在安装之前卸载以前的版本,并提示你卸载之前的版本信息。
以上是关于inno setup 之Deltree 用法的主要内容,如果未能解决你的问题,请参考以下文章