windowsinstallationinno-setup32bit-64bit

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


The constant {pf} is the directory of

C:\Program Files

for 32-bit systems and

C:\Program Files (x86)

for 64-bit systems.

However I want to use the directory

C:\Program Files

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


Solution

  • 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: