Visual Basic and Dll

I have to call from VB6 a function belonging to a Dll written by me in Windows ANSI C.
Function is Exported like this:
#define      EXPORT                        extern __declspec (dllexport)
EXPORT BOOL CALLBACK DllInitByPhonema(HWND);

From VB,I've a client that declare the function like this:
Declare Function DllInitByPhonema Lib "rtpbuffer.dll" _
(ByVal Hwnd As Long) As Boolean

and then call :
DllInitByPhonema(Me.Hwnd)

Problem is error 453 that is missing entry point in dll's function.Don't know why,'cause this is the standard procedure of calling function in system dll like kernel32 or user32.
Help please.
cbonjoviAsked:
Who is Participating?
 
zealsoftConnect With a Mentor Commented:
You use __declspec (dllexport) to export the funtion, VC++ and other C compiler will export the function as a C function. But VB supports only "stdcall" functions. So you need to change the C declation as follows,

BOOL __stdcall DllInitByPhonema(HWND);

And then create a .DEF file and add it into your VC++ project. In .DEF file, add following lines,

EXPORTS
   DllInitByPhonema

Recompile your DLL.
0
 
GustavoValdesCommented:
Becouse you're making a non Active X Dll, you must tell VB explicitly wich functions are available within your DLL, you do that by using a .DEF file that includes all the files that must be exportable.
0
All Courses

From novice to tech pro — start learning today.