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
Solved

Invoking an application thro DLL

Posted on 1998-07-02
6
190 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
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hibernate methods 2 77
lucky13 challenge 11 154
isEverywhere  challenge 19 82
java ^ examples 8 69
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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