Inno Setup 32bit and 64bit dll installation

2020-07-10 01:34发布

问题:

If the OS is 64bit I want to install a 32bit DLL to the Program Files (x86) folder and 64bit DLL to Program Files folder and register them respectively. If it is a 32bit OS I just want to copy the file to the normal program folder and register.

How can I do this in Inno Setup? Also will the 64bit DLL be registered by the 64bit regsvr32 program?

Here is my code so far. It works fine on 32bit OS but on 64bit OS it dumps both set of files in the Program Files (x86).

[Files]
Source: D:\..\32bit files\mylibrary.dll; DestDir: {app}; \
    Flags: restartreplace ignoreversion regserver 32bit

Source: D:\..\64bit files\mylibrary.dll; DestDir: {app}; \
    Flags: restartreplace ignoreversion regserver 64bit; Check: IsWin64

I have looked at the 64BitTwoArch.iss example but that tells how to do a 32bit OR 64bit install not a 32bit AND 64bit install.

回答1:

I have had success with the following:

[Files]
Source: D:\..\32bit files\mylibrary.dll; DestDir: {app}; \
    Flags: restartreplace ignoreversion regserver 32bit; **Check: "not IsWin64"**

Source: D:\..\64bit files\mylibrary.dll; DestDir: {app}; \
    Flags: restartreplace ignoreversion regserver 64bit; Check: IsWin64


回答2:

Couldn't get it to work with just the {app} variable because you want to install on two destinations simultaneously.

Solved it by hard coding the program files folder like this

#define MyAppName "TestAPP"

[Files]
Source: D:\..\32bit files\mylibrary.dll; DestDir: {pf32}\{#MyAppName}; \
    Flags: restartreplace ignoreversion regserver 32bit

Source: D:\..\64bit files\mylibrary.dll; DestDir: {pf64}\{#MyAppName}; \
    Flags: restartreplace ignoreversion regserver 64bit; Check: IsWin64

This works for me. Windows loads the 32bit dll for 32bit apps and 64bit dll for 64bit apps automatically this way.