필터 지우기
필터 지우기

loading an existing dll

조회 수: 3 (최근 30일)
JH
JH 2013년 8월 28일
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
Kaustubha Govind
Kaustubha Govind 2013년 8월 28일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by