+ Reply to Thread
Results 1 to 3 of 3

Thread: How DLL can call my function in main executable program?

  1. #1

    How DLL can call my function in main executable program?

    I want a DLL to call my function in main program.

    I can use SendMesage/PostMessage technique but that is not desired in my implementation. There is no GUI.

    Any help?

  2. #2
    There is a concept called callbacks or function pointer.

    You can use this concept to solve your problem.

    DLL can export a method which accepts a function pointer from the application.

    Application will need to register its function using this method.

    DLL will store this function pointer and execute this method whenever it requires.


    //this definition should be declared in header file so that it can be used by both Application
    //and DLL
    typedef void (*PFNCALLBACK)(void *pUserData) ;
    //RegisterCallback is a method exported from DLL..
    void RegisterCallback(PFNCALLBACK pfnCallback)
    	//DLL will store the pfnCallback pointer...
    	//Whenever DLL needs to call application function...
    	//It will make following call.

  3. #3
    Great, this is what I wanted. Thanks.

+ Reply to Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts