Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to access a 64-bit dll from a 32-bit application?

Tags:

64-bit

delphi

I have a Delphi application similar to Taskbar Shuffle that includes a hook dll.

EDIT: This hook DLL communicates with the main app by sending windows messages.

I want to add support to XP and Vista x64 and my initial idea was to convert the dll to 64-bit (compiling it with FreePascal) but keep the application 32-bit for now (Delphi).

Is it possible for a 32-bit application to access a 64-bit dll?

EDIT2: I'm loading the dll via LoadLibrary so I guess I'm stuck since a 32-bit process won't be able to load a 64-bit dll, according with what I read on the link pointed by Lars Truijens on one of the answers below.

like image 938
smartins Avatar asked Dec 04 '08 08:12

smartins


People also ask

Can a 32 bit application launch a 64-bit application?

The 64-bit versions of Windows don't provide support for 16-bit binaries or 32-bit drivers. Programs that depend on 16-bit binaries or 32-bit drivers can't run on the 64-bit versions of Windows unless the program manufacturer provides an update for the program.

How do I change a 32-bit DLL to 64-bit?

Solution 2. If possible create a separate 32 bits application that uses the 32 bit dll and call that using Process. Start()[^] from your 64 bits application. There are other ways like using named pipes for inter-process communincation, but they are quite complex to implement.


2 Answers

As long as the 64-bit DLL is being loaded by a separate 64-bit process, and all communication between 32-bit process and 64-bit DLL is via loose-coupled IPC-like mechanisms that the OS can marshall, then yes you can do that.

I've done something similar. A 32-bit application needed a custom Print Spooler add-in implemented in a DLL. The app and the spooler add-in communicated via IPC mechanisms (a fancy way of saying temporary files, in this case).

On 64-bit systems everything about the 32-bit application worked fine except that the Print Spooler refused to load the add-in DLL, because the Print Spooler was of course a 64-bit process.

The solution was as simple as rebuilding only the Spooler add-in in 64-bit. No need to change the entire 32-bit app.

like image 105
Daniel Earwicker Avatar answered Sep 30 '22 13:09

Daniel Earwicker


No. You'll have to compile two versions: 64-bit and 32-bit.

like image 25
Jeff Hubbard Avatar answered Sep 30 '22 12:09

Jeff Hubbard