![]() |
call C++ DLL from VBA
All,
I have finally (once again) managed to call a DLL from VBA. However, the only way I could get it to work was by building the DLL with the calling convention "__stdcall". I would like to use the "__cdecl" calling convention because the DLL is also called from Matlab. Does anyone know what to do? I am stuck getting the error message: Number 49: Description: Bad DLL calling convention TIA, Bill |
call C++ DLL from VBA
You probably need two entry points into your dll. One for matlab and one for
VBA. Put two subroutines into you DLL with different mames. Then have one routine call the other routine. That is exactly why the library definition statment in VBa has an Alias Public Declare Function FtpOpenFile Lib "wininet.dll" Alias "FtpOpenFileA" _ (ByVal hFtpSession As Long, ByVal sBuff As String, ByVal Access As Long, ByVal Flags As Long, ByVal Context As Long) As Long The Alias is the real routine that gets called internal in the DLL. For example if you wanted to build a DLL that worked with both winXP and Vista. WindXP is 32 bits and vista is 64 bits. So you would need some modification in the code to compensate for the difference in the data sizes. In your case the __cdecl indicates it is using C language calling convention and __stdcall uses standard calling convention. "Bill Grigg" wrote: All, I have finally (once again) managed to call a DLL from VBA. However, the only way I could get it to work was by building the DLL with the calling convention "__stdcall". I would like to use the "__cdecl" calling convention because the DLL is also called from Matlab. Does anyone know what to do? I am stuck getting the error message: Number 49: Description: Bad DLL calling convention TIA, Bill |
All times are GMT +1. The time now is 07:06 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com