There is a COM solution to the issue of loading a 32-bit DLL into a 64-bit application. JMP's JSL supports COM Automation on Windows. However, this would be a lot of work to wrapper the DLL using COM.
My Google Search:
using COM to marshal a 32-bit dll for a 64-bit application
AI response:
To call a 32-bit DLL from a 64-bit application, you need to use COM (Component Object Model) in an out-of-process server setup. This involves creating a separate 32-bit COM server application that acts as a wrapper for the 32-bit DLL. The 64-bit application can then communicate with this server through COM's inter-process communication mechanisms.
Here's a breakdown of the process:
1. Create a 32-bit COM Server Application:
-
New ATL Project:
Create a new ATL (Active Template Library) project in Visual Studio, specifically configured as an executable (not a DLL).
-
Add ATL Simple Object:
Add a new ATL Simple Object to the project. This will be the core of your COM server.
-
Implement Interfaces:
Define the interfaces (using .idl files) that the 64-bit application will use to interact with the 32-bit DLL.
-
Forward Calls:
Within the COM object's methods, forward the calls to the corresponding functions in the 32-bit DLL. This may involve marshalling data between the two processes.
2. Register the COM Server:
-
You'll need to register the COM server using DllSurrogate. This allows the 64-bit process to instantiate the 32-bit COM object out-of-process.
-
Registry Entries:
Ensure the necessary registry entries are created to allow the 32-bit in-process server to be loaded by the system's DllSurrogate.
3. Consume the COM Server in the 64-bit Application:
-
Create a COM Client:
.
In your 64-bit application, create a COM client that connects to the 32-bit COM server. You will use the COM interfaces defined in the .idl file.
-
Inter-process Communication:
.
COM handles the inter-process communication, marshalling data between the 64-bit and 32-bit processes.
-
Interface Definitions:
Ensure the interfaces defined in the 64-bit application's COM client and the 32-bit server are compatible, including data types and method signatures. Consider using IDL (Interface Definition Language) to define the interfaces.
-
-
Performance:
While COM provides inter-process communication, it introduces overhead. For performance-critical applications, consider the impact of this overhead.
-
By using this approach, you can successfully integrate a 32-bit DLL into your 64-bit application, leveraging the power of COM for inter-process communication and data marshalling.