Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Wouldn't know what to call it! | Excel Worksheet Functions | |||
How to call this DLL? | Excel Programming | |||
Call Center Management: How to calculate 'cost per call' | Excel Discussion (Misc queries) | |||
Run or Call | Excel Programming | |||
call sub | Excel Programming |