How to declare a callback function for use by a DLL 
Author Message
 How to declare a callback function for use by a DLL

I am writing a dll that needs to execute a function in the main app
later. I want to declare the function as a parameter to one of my dll
functions, so the dll can store the function pointer and call the
function in the app later. This should be simple but I can't figure out
the syntax. How exactly do I declare the dll function to take a
callback function as a parameter? And how exactly do I call it back
from the dll?

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 04 May 2003 03:00:00 GMT  
 How to declare a callback function for use by a DLL
Greets,

    Now would be a good time to do a little more research on function
pointers.  Typically, I've found that using a typedef for a function point
certainly helps when passing them as arguments.  One typical way one could
do this:

    typedef int (*MYFUNCPTR)(int x);
    void SomethingToCallback(MYFUNCPTR pFunc);

void
SomethingToCallback(
MYFUNCPTR pFunc)
{
    int x=pFunc(10);

Quote:
}

Regards,

Joe

Quote:

> I am writing a dll that needs to execute a function in the main app
> later. I want to declare the function as a parameter to one of my dll
> functions, so the dll can store the function pointer and call the
> function in the app later. This should be simple but I can't figure out
> the syntax. How exactly do I declare the dll function to take a
> callback function as a parameter? And how exactly do I call it back
> from the dll?

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 04 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Howto: declare a C function that registers a callback in IDL

2. how do i declare callback functions

3. Creating a DLL; Declaring DLL Functions

4. Using Non-Static Callback Functions as member Functions VC5.0

5. How to declare NT-DLL Functions in WATCOM-C

6. Declaring exportable functions in DLL

7. HELP! Declaring/Using a DLL

8. DLL function declare as APIENTRY

9. Help required using a CallBack function

10. Using timer-callback-function

11. Using a C++ member function as a Timer callback

12. Using Non-Static Callbacks as member functions VC 5.0

 

 
Powered by phpBB® Forum Software