Solved

CallBack Function

Posted on 1998-07-02
3
176 Views
Last Modified: 2010-04-15
I am making a DLL, that at certain point should call back some function in my main EXE.

How to do this?

I need a small example of exported DLL function, that will receive information about address of call-back function in EXE, and example of calling call-back function from DLL.

I am using MS VC, and I work in plain C.
0
Comment
Question by:yuhoo
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
faster earned 50 total points
ID: 1251530
In your dll, you should first have the definition of the prototype of the function you want to call,for example:

typedef int (*EXEEXPORTPROC)(void *,void *);

then the exe should pass the function pointer to the dll, after the dll get the pointer, say lpfunc, you can simply call it like:

lpfunc(param1, param2)


0
 

Author Comment

by:yuhoo
ID: 1251531

      I can't follow you, Can you give me real example?

I suppose I should define lpcfunc as:

EXEEXPORTPROC *lpcfunc;

but how to define function that retrieves EXE's function pointer?
0
 
LVL 7

Expert Comment

by:faster
ID: 1251532
It is easy, just have another function defined in DLL:

setFuncPointer(EXEEXPORTPROC lpcfunc);

Let the exe call this function and pass the pointer in.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question