Solved

Communication from DLL to a application

Posted on 1998-06-15
2
199 Views
Last Modified: 2013-11-20
How can I call a function in the application from the DLL ?
Is it possible thro CALLBACK? If so please specify how?
Thank U
0
Comment
Question by:aac
2 Comments
 
LVL 1

Accepted Solution

by:
IgorGrebnev earned 10 total points
ID: 1317957
Dear aac,

You can transfer the pointer to funciton in executable to DLL through pointer to function. The following code can be used
In EXE:

int ExportedFromEXEFunc()

{ return 0;
}

In DLL you should implement the following:

typedef int (*typePtrExpFunc)();

static typePtrExpFunc stm_pFunc = NULL;
 
declspec(_dllexport) void SetEXE_ExportedFunc( typePtrExpFunc pfExpFunc )

{stm_pFunc = pfExpFunc;
}

After calling the SetEXE_ExportedFunc from EXE and setting of static pointer to funciton in executable you can call the function through pointer anywhere in DLL:

(*stm_pFunc)();

0
 

Author Comment

by:aac
ID: 1317958
Instead of using declspec to export the function can I use it directly in my .def file?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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