?
Solved

Invoking an application thro DLL

Posted on 1998-07-02
6
Medium Priority
?
198 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
[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
6 Comments
 
LVL 1

Accepted Solution

by:
sudhirbrat earned 30 total points
ID: 1318625

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
ID: 1318626
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
ID: 1318627
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
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 

Author Comment

by:akhila
ID: 1318628
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
ID: 1318629
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
ID: 1318630
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

800 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