Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CallBack Function

Posted on 1998-07-02
3
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
faster earned 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them 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.

598 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