我已经使用Inno Setup创建了一个包含5个文件的安装程序。我添加了一个附加功能,以便用户可以在自定义路径中安装它。
安装后,将在所选路径中创建一个文件夹。现在,我将在此文件夹中复制一些其他文件。但是,在卸载后,会发生以下情况:
让用户将其安装在默认位置,然后在该位置创建一个名为myfolder的新文件夹,现在用户创建2个新文件并将其复制到该文件夹中。卸载后没有问题;myfolder将与2个新文件(在安装后创建)一起删除。
现在,让用户在自定义位置安装它,然后在该位置创建一个名为myfolder的新文件夹,现在用户创建2个新文件并将其复制到该文件夹中。卸载myfolder后不会删除,因为其中包含2个新文件(安装后创建)。
这是我的代码:
function GetInstalledLocation(): String;
var
installLocation: String;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ {36CBFC-6ACC-4232-90CF-E95BC473C168}_is1') then
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1536CBFC-6ACC-4232-90CF-E95BC473C168}_is1', 'InstallLocation', installLocation);
Result := installLocation
end;
end;
function InitializeUninstall(): Boolean;
var
InstalledLocation : String;
begin
Result := PromptUntilProgramClosedOrInstallationCanceled( ProgramRunningOnUninstallMessage, True );
// Unload the DLL, otherwise the dll psvince is not deleted
UnloadDLL(ExpandConstant('{app}\psvince.dll'));
if not Result then
begin
MsgBox( UninstallationCanceledMessage, mbInformation, MB_OK );
end
else
begin
InstalledLocation := GetInstalledLocation();
;DelTree('{InstalledLocation\*}', True, True, True);
DelTree('{InstalledLocation}', True, True, True);
; DelTree('ExpandConstant({InstalledLocation\*})', True, True, True);
end;
end;
[UninstallDelete]
;This works only if it is installed in default location
Type: filesandordirs; Name: "{pf}\{#MyAppName}"
但是我想删除文件夹以及新文件,即我想在inno setup中删除非空文件夹。我该怎么做 ?
ya现在它正在工作,我使用了以下代码:
[UninstallDelete]
;This works only if it is installed in default location
Type: filesandordirs; Name: "{pf}\{#MyAppName}"
;This works if it is installed in custom location
Type: files; Name: "{app}\*";
Type: filesandordirs; Name: "{app}"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句