loading an existing dll
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all-
I want write a C++ s-function that accesses/loads an existing dll. I have an existing example calling the dll using fortran:
REAL(4) :: avrSWAP(*)
INTEGER(4) :: aviFAIL
INTEGER(1) :: accINFILE(*)
INTEGER(1) :: avcMSG(*)
INTEGER(1) :: avcOUTNAME(*)
INTEGER(HANDLE) :: FileAddr
INTEGER(LPVOID) :: ProcAddr
POINTER ( DLL_ProcAddr, DLL_Procedure )
INTERFACE
SUBROUTINE DLL_Procedure(avrSWAP,aviFAIL,accINFILE,avcOUTNAME,avcMSG)
REAL(4) :: avrSWAP (*)
INTEGER(4) :: aviFAIL
INTEGER(1) :: accINFILE (*)
INTEGER(1) :: avcMSG (*)
INTEGER(1) :: avcOUTNAME(*)
END SUBROUTINE DLL_Procedure
END INTERFACE
FileAddr = LoadLibrary( "DISCON.DLL" )
ProcAddr = GetProcAddress( DLL_Trgt%FileAddr, "DISCON" )
DLL_ProcAddr = ProcAddr
CALL DLL_Procedure ( avrSWAP, aviFAIL, accINFILE, avcOUTNAME, avcMSG )
Is there an example of doing something similar from a C++ s-function? The interface is clear from the fortran code, but I do not have the header file or the code for this dll. I am quite confident that I can write/hack my own C++ header for it if that is necessary. If anyone wants to take a crack at actually writing the necessary C++ code to load and call the dll, that would be absolutely terrific. Otherwise, just a simple example of a C++ s-function calling any dll would be fantastic as well.
Thanks for any and all help,
-Jason
1 Commento
Kaustubha Govind
il 28 Ago 2013
JH: S-functions support standard C usage (I think it's the C99 standard, but it probably depends on what MEX compiler you're using), so I would recommend that you attempt to first write standalone C/C++ code that uses the DLL outside of MATLAB, and test it out. Once you have that working, you can use the same type of call in an S-function.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!