Setting Inno and DefaultDirName

Is there any way to set DefaultDirName by code depending on any division that the user performed during installation?

Let me comment: I have code that is generated for two different systems (using different interops / ocx, etc.). My input files are stored in two input directories \ A and input \ B. I want to have only one setup file for both systems.

In the installation file, I use CreateInputOptionPage with two parameters to determine which files to install (by checking for each file). This is working fine.

But I also have ShellExec shell at the end of the installation, which currently uses {app}, for example, register some .Net classes and ShellExec to unregister .Net classes on InitializeUninstall (also uses {app})

The installation should install the software in two different places (depending on the user's choice (for example, c: \ software_a or c: \ software_b). It is impossible to change this.

So, is there a way to specify DefaultDirName before the files are copied to the system, so I can use the same ShellExec when installing and uninstalling? I could, of course, add the same ShellExec for both systems during installation and use if to check which files are logged (depending on the user's choice), but when uninstalling I won’t have this information (user choice), so I don’t I can unregister .Net.

thank

+3
source share
2 answers

If you need to change the installation folder after initializing DefaultDirName, this works pretty well for me:

procedure CurPageChanged(CurPageID: Integer);
begin
  { updates the install path depending on the install type or the entered suffix }
  if CurPageID = wpSelectDir then begin
     WizardForm.DirEdit.Text := ExpandConstant('{pf}') + '\MyAppName' + GetAppSuffix('');
  end;
end;

Greetings Chris

+1
source

CreateInputOptionPage , . , .

[Setup]
DefaultDirName={code:getpath}

[Code]
function GetPath( Default: string ): string;
begin

if (CreateInputOptionPageValue1) then
 Result := ExpandConstant({sd}) + '\path1';
else
 Result := ExpandConstant({sd}) + '\path2';
end;
+3

Source: https://habr.com/ru/post/1774779/


All Articles