loading an existing dll

1 visualización (últimos 30 días)
JH
JH el 28 de Ag. de 2013
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 comentario
Kaustubha Govind
Kaustubha Govind el 28 de Ag. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by