Does anyone know how to call an external DLL from Intel Fortran? I don't have the source code for the DLL, but I know its exported function name and the details of the list of parameters I need to pass to it.
The DLL is called EMG.DLL and the function inside that I want to call is called EMGSub. I can call it Ok from a C program but I want to do it directly from Fortran.
I have tried doing it using LoadLibrary and GetProcAddress as follows:
hHandle = LoadLibrary("EMG.DLL"C)
IF (hHandle.EQ.0) THEN
CALL MSGBOX("Could not load EMG.DLL"C)
hProc = GetProcAddress(hHandle, "EMGSub"C)
IF (hProc.EQ.0) THEN
CALL MSGBOX("Could not find EMGSub in EMG.DLL"C)
CALL EMGSub(A,B,C,D) <= This generates a linker "Unresolved external" error
I realise that the above won't work because I haven't linked my EMGSub call to the hProc procedure handle. How do I link them and then do the call?
Is there any easier way that avoids the need for LoadLibrary and GetProcAddress?