0
我已经创建了一个使用Inno Setup的安装程序,其中包含5个文件。我添加了一个附加功能,以便用户可以将其安装在自定义路径中。如何删除inno setup中的非空文件夹
安装后,将在所选路径中创建一个文件夹。现在我将复制此文件夹中的其他文件。但未安装后,以下情况发生:
让用户将其安装在默认的位置,然后一个新的文件夹说MyFolder文件是在该位置创建,现在用户创建该文件夹中的2个新的文件,并将它们复制。 卸载后没有问题;我的文件夹将与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}"
但我想用新的文件,即我要在创新安装,删除非空文件夹一并删除文件夹。 我该怎么办?
的可能重复(http://stackoverflow.com/questions/643547/how-to -configure-inno-setup-to-uninstall-everything) –
正如在链接问题中所建议的,这样做是一个坏主意。 – Miral