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 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

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

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui