Solved

CallBack Function

Posted on 1998-07-02
3
175 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

777 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