Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup: Use "Program Files" directory on both 32bit/64bit systems with {pf}

The constant {pf} is the directory of

C:\Program Files

for 32bit systems and

C:\Program Files (x86)

for 64bit systems.

However I want to use the directory

C:\Program Files

for both, 32 and 64bit systems. How can I achieve this?

like image 427
Ben Jost Avatar asked Jul 18 '16 18:07

Ben Jost


1 Answers

Use a scripted constant like:

[Setup]
DefaultDirName={code:GetProgramFiles}\My Program
[Code]

function GetProgramFiles(Param: string): string;
begin
  if IsWin64 then Result := ExpandConstant('{commonpf64}')
    else Result := ExpandConstant('{commonpf32}')
end;

Though this approach should only be used, if you generate binaries for the respective platform on the fly. Like in your case, if understand correctly, you compile the Java binaries for the respective architecture.


You can also use 64-bit install mode.

Then you can simply use {autopf} constant (previously {pf}):

[Setup]
DefaultDirName={autopf}\My Program

If you have a separate 32-bit and 64-bit binaries in the installer, use a script like:

[Files]
Source: "MyDll32.dll"; DestDir: "{pf32}\My Program"; Check: not IsWin64
Source: "MyDll64.dll"; DestDir: "{pf64}\My Program"; Check: IsWin64

See also:

  • Is it possible to set the install mode in Inno Setup (32 or 64 bit)?
  • Inno Setup 32bit and 64bit dll installation
like image 120
Martin Prikryl Avatar answered Oct 05 '22 23:10

Martin Prikryl