0

I need to use the function SetEventCallback in 3rd party dll.

void  __stdcall SetEventCallback(void __stdcall callbackFunc(int val))

This function registers callbackFunc as callback function of some registered events. If an event occurs, callbackFunc is called and you could know which event is occured through parameter val.

I want to know how to use the function SetEventCallback.


I tried using it as follows.

  1. Import function in dll
extern "C" __declspec(dllimport) void  __stdcall SetEventCallback(void __stdcall callbackFunc(int val));
  1. Define callback function in my application
void __stdcall callbackInApp(int val) {

    if(val == 0) {
        // Do something with val
    }
    else {
        // Do something with val
    }  
}
  1. Call function SetEventCallback by passing the function pointer as parameter
int main(void) {
 
    SetEventCallback(callbackInApp);
}

Compilation is success but callbackInApp is never called. Please let me know how to fix it.

HJ Kim
  • 1
  • Hopefully the 3rd party DLL came with some documentation. Everything you need to know should be described in it. If it isn't, then you are out of luck. At least you should tell us what that 3rd party DLL is... – U. W. Apr 08 '21 at 09:12
  • Looking at the code shown, you're passing your callback correctly. The issue is elsewhere. – rustyx Apr 08 '21 at 09:13
  • How do you know it's never called? – CristiFati Apr 08 '21 at 18:00
  • @CristiFati I did debugging line by line and the callback function was never called. I think the registering was not worked. – HJ Kim Apr 09 '21 at 01:42
  • Unfortunately, there are no documents for this 3rd party DLL. Since this is private service module, I can't even expain what this module is. I asked question here to get answers fast, but I think I can't give you full information about the problem. I think I should contact to developer even if it takes several days to get answer. Thanks to all of you. – HJ Kim Apr 09 '21 at 01:43

0 Answers0