Solved

Invoking an application thro DLL

Posted on 1998-07-02
6
182 Views
Last Modified: 2013-11-19
How can I invoke an application from the DLL based on some event etc. like my DLL should automatically call some function in my application.
Thank U
0
Comment
Question by:akhila
6 Comments
 
LVL 1

Accepted Solution

by:
sudhirbrat earned 10 total points
Comment Utility

Akhila
You can write an export function in application just like as you write in DLL, and declare the function in the DLL and call the function from DLL.

It worked for me. Try it.
0
 

Author Comment

by:akhila
Comment Utility
Should I specify that export function as import in my DLL?
One more doubt...Can I do this same thing across applications ie if my DLL is being used by
two applications, the process spaces will be different. Wont it be a problem to call the functions in that case?
Kindly explaing. I'll try the above.
0
 
LVL 2

Expert Comment

by:rayb
Comment Utility
You're trying to get the DLL to call into the application that loaded the DLL in the first place?  If so, you'll need to implement some form of callback communications, i.e. your application will have to register a function with the DLL.  This way, when the certain event occurs within the DLL, the DLL can call that registered function.

And, yes, you can use this across different applications, when a DLL is loaded by multiple applications, the memory where the code exists may be shared, but never the data.

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:akhila
Comment Utility
Rayb,
   Thank U for the answer. I have already used the callback function registering etc..But the problem arises when I use it across the applications. I have 2 applns. and each appln has a different function which has to be called. The applications register their callback functions with DLL. Registering is I just call a function in DLL to which I pass the appln function pointer. I store these function pointers in a global array which is declared  as a shared segment. So, when the function of another appln is invoked in the DLL( which in turn is invoked by another appln) I get an error that the function is out of address space.
Kindly help me.

0
 
LVL 2

Expert Comment

by:SamratAshok
Comment Utility
Why dont you define a class in DLL with virtual function, derive it in your app and then
use it as a lot simpler callback mechanism.

0
 

Author Comment

by:akhila
Comment Utility
SamratAshok.
   Even though I derive an virutal function, That function is valid only in the context of my application ie it will be invalid if multiple applications are accessing my DLL and the function in one application is invoked through another application (because the process spaces differ). I want a solution such that my dLL gets invoked on some event automatically and calls the correspoding function in the corresponding application (assuming that all the required function pointers of an application are given to the DLL).
Thank You
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 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

17 Experts available now in Live!

Get 1:1 Help Now