Solved

Communication from DLL to a application

Posted on 1998-06-15
2
197 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatSeparator  java  challenge 13 56
zeroMAx challenge 20 87
Line meaning 9 81
Excel file not created as expected 7 48
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

15 Experts available now in Live!

Get 1:1 Help Now