Calling CDecl funcitons in a DLL from VB+
Posted on 1998-01-13
We would like to call DLL functions from a dll written in C Laguage. We all know that it is ok to do so in VB if the dll use standart declarations, but we have a problem here. The dll we want to call the function from, is entire wirtten using the C_Declare, what turns impossible(?!?) to call them.
In order to avoid to use all those non-professional OCXs and VBXs and other Computer Telephony toolkits, we would like to call the Dialogic boards directly throu their dll, using their API. Using their dlls directly we will be able to save about 90% of memory and also we will be able to use threads.
We have all the documentation to convert the *.H files to *.bas files. For exemple:
-in the *.h file we have:
extern int dx_open( const char *namep, int oflags );
-what becomes a *.bas file in VB5:
declare function dx_open& lib "libdxxmt.dll" (byval char as string, byval oflags as long)
The problem is that we will get a"Bad DLL calling convention" anyway. The DLL is is not acessible from VB becuse it is expecting a "standart declaration".
We have been searching the web and asking the PROs, and it seems that we would have to either re-write the dll using standart declaration (which is impossible since it is how the toolkit developers makes money) or write a "Wrapper DLL" to translate the calls.
The DLL vendor told me that it's necessary to write a "wrapper" DLL in C
language to translate the calls.
We would like to know if there is a work around, and how can we write a multithreaded wrapper dll without the original dll source code..
I Hope this helps, and I hope someone helps me!
Thanx in advance...