
Callback to a VB function
Try typefeding callback as __stdcall:
typedef long (WINAPI *CallbackPtr_t)(long);
extern "C" __declspec(dllexport) long WINAPI
DoSomethingWithCallback(long TheNum,
CallbackPtr_t CallbackPtr)
{
long RetVal;
RetVal = CallbackPtr(TheNum);
return RetVal;
Quote:
}
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Quote:
> From a VB program, I am passing a function pointer to a
> function in a C++ dll. The C++ function calls my VB
> callback function just fine. After control returns to my
> C++ function, the application crashes. I suspect that
> this has something to do with calling conventions, and
> that the stack is being handled improperly. Sample code
> for my C++ function is below:
> extern "C" __declspec(dllexport) long WINAPI
> DoSomethingWithCallback(long TheNum,
> long (* CallbackPtr)(long))
> {
> long RetVal;
> RetVal = (* CallbackPtr )(TheNum);
> return RetVal;
> }
> Please help!