I have a 32-bit exe that needs to dynamically load a 64-bit dll when it detects that the operating system is 64-bit. Is this possible through LoadLibrary? If not, is there another way to accomplish the same goal?
On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL.
The recommended solution is to recompile the DLL from the source code for a 32-bit target architecture. Alternatively, you can load the DLL in a 64-bit LabVIEW VI or EXE and communicate between 64-bit LabVIEW and 32-bit LabVIEW using Shared Variables or other networking technologies.
If the first DLL in the path is 32 bit and your app is 32 bit, then the DLL load will work. If the app is 64 bit, it will fail to load the DLL and the process will abort. If you want two DLLs to coexist on the system path, you need to give them unique file names.
As previously mentioned, 32-bit code cannot load 64-bit code in the same process. You'll have to load it into a different process (CreateProcess() ?) and use IPC to coordinate.
You can't mix 64-bit and 32-bit code in the same process. You'll need a 32-bit version of the DLL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With