Inno Setup 32bit and 64bit dll installation

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

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.