What is proper syntax for DLL calls

What is proper syntax for DLL calls

In fortran I have
subroutine HSEALH_2010()
!DEC$ ATTRIBUTES DLLEXPORT :: HSEALH_2010

I have been successful calling this from Excel visual basic if the subroutine has no arguments, but I can't get it to work with any arguments. Can someone give me an example or two of how to do this with arguments?
Thanks,
Brian in Austin, Texas

3 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

You need STDCALL, REFERENCE and ALIAS:

!DEC$ ATTRIBUTES DLLEXPORT,STDCALL,REFERENCE,ALIAS:"HSEALH_2010" :: HSEALH_2010

STDCALL is needed because VB/VBA uses it. WIthout that, you can corrupt the stack if you have arguments. REFERENCE is needed to offset the default pass-by-value of STDCALL.  ALIAS is needed to set the name you'll use from VBA.

There is a worked example provided called, of all things, EXCEL, under MixedLanguage. I suggest you study it.

Steve - Intel Developer Support

I see!, said the blind man.
That was exactly what I needed, and it now works perfectly.
Thanks for the tip about the EXCEL sample project. It shows how to pass a string to fortran and I didn't know how to do that. That will come in handy.
Cheers,
Brian

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi