Solved

CallBack Function

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
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.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now