7

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Ali
  • 309
  • 1
  • 3
  • 12
  • 3
    If you want both files to be installed on 64-bit Windows and the destination folder to be different for each, then you can't use the same `DestDir` for both. There isn't a "nice" solution for installing them in different folders either, because that's not actually something that you're supposed to do (and you can't guarantee that {app} is under {pf} anyway). The best solution is to either install only the one file that matches the OS, or to install them both in the same folder with different filenames. – Miral Jul 30 '13 at 20:51
  • I second what @Miral says. You _could_ do it using a bunch of ugly string operations on {app}, but there's no guarantee the user will install it in {pf} in the first place. – Nyerguds Jun 28 '16 at 12:49

2 Answers2

4

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
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
GAR8
  • 293
  • 1
  • 5
  • 14
  • the destdir is {app} for both. Wouldn't it copy both the 64 and 32bit to the same location then? I'd like the 64bit copied to the 64bit program files location and 32bit to the x86 program files. – Ali Jul 30 '13 at 16:26
  • No, it will only copy the version that matches the bit of the system. Per Inno Help: "Causes the {sys} constant to map to the 64-bit System directory when used in the Filename and WorkingDir parameters. This is the default behavior in a 64-bit mode install. This flag can only be used when Setup is running on 64-bit Windows, otherwise an error will occur. On an installation supporting both 32- and 64-bit architectures, it is possible to avoid the error by adding a Check: IsWin64 parameter, which will cause the entry to be silently skipped when running on 32-bit Windows." – GAR8 Jul 30 '13 at 20:15
  • This does not answer the question, as it indeed installs both files to the same location (the `{app}` resolves to installation folder selected by user, it won't magically map to 64-bit equivalent when `64bit` flag is used). On the other hands, this is the correct solution for most cases. For example if your application is 32-bit, but also has 64-bit version shell extension, you still install the shell extension along with the rest of the binaries to the 32-bit "Program Files". But you use the `64bit` flag to make it register for 64-bit. – Martin Prikryl Feb 28 '16 at 07:04
3

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Ali
  • 309
  • 1
  • 3
  • 12
  • 1
    I get the error: "Unable to register the DLL/OCX: RegSvr32 failed with exit code 0x4" when I run the above script. My guess is that my x64 Windows does not handle well the inclusion of x86 registration. Is there a way to handle this? – Chagbert Jun 04 '15 at 14:30
  • That seems to be a problem with registering a component rather than copying files. Try running regsvr32 and the component by itself and see the problem. Make sure you are using the 32bit regsvr32 if it is a 32bit dll. By default it may use the 64bit regsvr32. Also make sure the installer has the right admin privilege. https://support.microsoft.com/en-us/kb/282747 – Ali Jun 04 '15 at 17:15
  • While this does what the question asks for, generally the correct solution is [the answer by @GAR8](http://stackoverflow.com/a/17949964/850848). You do not want to install one lone 64-bit DLL to 64-bit "Program Files". You keep it with the rest of the binaries for your (supposedly) 32-bit application. – Martin Prikryl Feb 28 '16 at 07:06