如何在inno设置中删除非空文件夹

beg*_*ner 6 directory inno-setup

我使用Inno Setup创建了一个安装程序,其中包含5个文件.我添加了一个附加功能,以便用户可以将其安装在自定义路径中.

安装后,将在选定路径中创建一个文件夹.现在我将复制此文件夹中的其他一些文件.但在卸载后,会发生以下情况:

  1. 让用户在默认位置安装它,然后一个新文件夹说在该位置创建了myfolder,现在用户创建了2个新文件并将它们复制到该文件夹​​中.卸载后没有问题; 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}"
Run Code Online (Sandbox Code Playgroud)

但我想删除文件夹和新文件,即我想在inno设置中删除非空文件夹.我该怎么做 ?

beg*_*ner 10

你现在正在工作,我使用以下代码:

[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}"
Run Code Online (Sandbox Code Playgroud)