Re: recompile a DLL with _stdcall for VB
<pink0.pallino@libero.it> wrote:
`CALLBACK' is defined as `__stdcall' in WinDef.h header.
Alex- Hide quoted text -
- Show quoted text -
thnk you for the replay.
well, this is the error I get when I try to compile the
dll:
error C2059: syntax error : '__stdcall'
the functions are so written:
BOOL STDDLLEXPORT myfunctionSTD(int nvalue, void
(CALLBACK*
amIReadyCallback)(int, LPVOID), LPVOID lpvParameter)
{ //function wrapper for VB
BOOL value;
value= myfunctionCDECL( nvalue,(CALLBACK*
amIReadyCallback)(int,
LPVOID), lpvParameter); <---here I get the error
return value;
}
You get the error because you supplies type info along the
parameter. You don't need it:
BOOL STDDLLEXPORT myfunctionSTD(
int nvalue,
void (CALLBACK* amIReadyCallback)(int, LPVOID),
LPVOID lpvParameter
)
{ //function wrapper for VB
BOOL value = myfunctionCDECL(
nvalue, amIReadyCallback, lpvParameter);
return value;
}
Tt will be much easier for you if you use typedef to reduce
syntax clutter:
typedef void (CALLBACK* MYFUNC)(int, LPVOID);
BOOL STDDLLEXPORT myfunctionSTD(
int nvalue,
MYFUNC pFunc,
LPVOID lpvParameter
)
{ //function wrapper for VB
BOOL value = myfunctionCDECL(
nvalue, pFunc, lpvParameter);
return value;
}
so my questions are:
do I need to write a wrapper for the myFunctionCDECL ?
if yes, how do I call the callback function inside the
wrapper?
Yes, you need to write a wrapper. Here's description of how
to do it:
KB153586 - "How To Call C Functions That Use the _cdecl
Calling Convention"
http://support.microsoft.com/kb/153586
HTH
Alex