Directory 如何在inno安装程序中删除非空文件夹
我已经使用Inno安装程序创建了一个安装程序,其中包含5个文件。我添加了一个附加功能,以便用户可以在自定义路径中安装它 安装后,将在所选路径中创建文件夹。现在我将复制此文件夹中的其他一些文件。但在卸载后,会发生以下情况:Directory 如何在inno安装程序中删除非空文件夹,directory,inno-setup,Directory,Inno Setup,我已经使用Inno安装程序创建了一个安装程序,其中包含5个文件。我添加了一个附加功能,以便用户可以在自定义路径中安装它 安装后,将在所选路径中创建文件夹。现在我将复制此文件夹中的其他一些文件。但在卸载后,会发生以下情况: 让用户在默认位置安装它,然后在该位置创建一个新文件夹,比如说myfolder,现在用户创建2个新文件并将它们复制到该文件夹中。 卸载后没有问题;myfolder将与2个新文件(安装后创建)一起删除 现在让用户在自定义位置安装它,然后在该位置创建一个新文件夹,比如说myfolde
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安装程序中的非空文件夹。
我该怎么做呢?现在它可以工作了,我使用了以下代码:
[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}"
可能重复链接问题中的建议,这样做是个坏主意。