• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

Invoking an application thro DLL

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
akhila
Asked:
akhila
1 Solution
 
sudhirbratCommented:

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
 
akhilaAuthor Commented:
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
 
raybCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
akhilaAuthor Commented:
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
 
SamratAshokCommented:
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
 
akhilaAuthor Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now