MATLAB: Error loading a 32bit DLL with 64bit Matlab

loadlibrary

I am trying to load a 32bit DLL using loadlibrary() in R2012a 64bit matlab on window 7. I have both the DLL and h files. I have added the DLL and h file locations to the environment path variable and matlab path.
The error I get from loadlibrary() is: dllname.dll is not a valid Win32 application.
While searching for an answere to my problem I have noticed Kaustubha Govind has stated the answer below several times:
  • The "is not a valid Win32 application" error usually means that you are attempting to load a 32-bit DLL using 64-bit MATLAB. Perhaps there are no 64-bit versions of the NI DLLs available? You can try installing 32-bit MATLAB on your 64-bit machine and see if you are able to load the libraries from that installation.
I do not have a 64bit version of the DLL available.
Is there any way to load 32bit dll a 64bit matlab?

Best Answer

Sorry, it is not possible to load a 32 bit dll from a 64 bit windows executable. This is an operating systems limitation (and also a limitation in the machine architecture.)