this is the callback function:
**Each of last parameter (void *data/details) carry a pointer which contain data structure.
typedef void(__stdcall * T_OperationMethod) (LONG32 Id, LONG32 operation, LONG32 result, LONG32 summary, void *data) typedef void(__stdcall * T_StaMethod) (LONG32 status, LONG32 result, LONG32 summary, void *details) typedef void(__stdcall * T_InterMethod) (LONG32 Id, LONG32 operation, LONG32 summary, void *data)
this is the API command that i wish to call with the callback function as parameter:
typedef signed long INT32 typedef INT32 T_Result DLL_API T_Result CALLTYPE test_Open(T_OperationMethod operation, T_StaMethod status, T_InterMethod intermediate )
[in] operation Callback function for operation event.
[in] status Callback function for status event.
[in] intermediate Callback function for intermediate event.
What i have done in Vb6 is as follows to equivalent the code above for enable me to call the API and also the callback function:
i had create sub procedure for the api to callback as callbackfunction:
Public Sub onOperation(ByVal Id&, ByVal operation&, ByVal result&, ByVal summary&, ByRef data As Long) Public Sub onStatus(ByVal status&, ByVal result&, ByVal summary&, ByRef details As Long) Public Sub onIntermediate(ByVal Id&, ByVal operation&, ByVal summary&, ByRef data As Long)
API command Delcaration equivalent to the C:
Public Declare Function test_Open Lib "testCtlW32.dll" (ByVal operation As Long, ByVal status As Long, ByVal intermediate As Long) As Long
Passing address of the callback function:
Dim lngReturn as long lngReturn = bnr_Open(AddressOf onOperation, AddressOf onStatus, AddressOf onIntermediate)
However, I encounter error as the application crashed and it seem like my callback function is not working at all where by the function parameter or the function is not been called. Is there anything that i missed out?or the implementation of callback function i had done is wrong?
I had try to change the data type and also byval/byref change but it seem nothing is working.
When the application crashed the event viewer put this description as follows:
Faulting application project1.exe, version 22.214.171.124, faulting module msvbvm60.dll, version 126.96.36.199, fault address 0x000e47f2.
Any Advice?Is it any crash in the memory address location?due to wrong parameter data type or my method calling (call back function "address of" is wrong)
Thank You in advance.