Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,

I could not find the answer in websites, if any body knows please clarify,

DLL and Executable are running in same machine and dll has send message to executable regards to completed the process(ex: Loading data/resource from dll).

How DLL can intimate the executable?



Regards,
Ranjith
Posted
Comments
pasztorpisti 9-Oct-13 10:01am    
Are these (the exe and the dll) reside in the same process? I can not decide which one is your scenario:
1. Your exe tries to communicate with another process/exe that loads your DLL.
2. Your exe loads your dll within the same process and you just want to perform function calls from the exe to the dll and vice versa.
ranjithkumar81 11-Oct-13 3:45am    
Dll and exe are running on different process.
No, example exe is running one thread and dll is running another thread. Dll is providing some data/information to exe and at certain point dll needs to intimate to the exe my work is completed.
how to achieve this problem.
ranjithkumar81 11-Oct-13 5:03am    
different process

You can use what Mike described (callback)... but if this is for Windows... I'd use Windows messages. Why? ...because once you have figured out the technique, it's easy to add/remove messages without changing the DLL interface (depends on whether you care about a changing a DLL interface or not).

Here's an article about Windows messages with MFC, but if you're not using MFC, you can also do it through the raw WinAPI (and it's pretty easy to do so as well):
http://msdn.microsoft.com/en-us/library/6d1asasd.aspx[^]
 
Share this answer
 
Comments
pasztorpisti 11-Oct-13 9:41am    
+5, a windows message is indeed a simple and viable option in many cases.
Albert Holguin 11-Oct-13 11:03am    
thanks
It doesn't matter if the code is in a DLL or an EXE inside the processes. The important thing is that you have two processes that have to communicate with each other. I assume that the communication doesn't have to use async message passing (Message passing, i.e.: both processes are running when the communication has to be performed.

In this case you have to choose and use an IPC mechanism: Windows Interprocess Communications
The two most basic communication methods from the listed windows IPC mechanisms are pipes and sockets.
My personal favorite is sockets because:
- Its easy to port to any platform
- Easy to run the processes on separate machines and communciation code is still the same
- Easy to use it between programs written in different languages
- loopback communication (when both endpoints are on the same machine) is optimized on all major platforms so using sockets locally is as effective as using pipes
 
Share this answer
 
v2
Use a Callback.

See this article for examples: Type-safe Callbacks in C++[^]
 
Share this answer
 
v2
Hi,

I think you need but I'm not sure

How to load a dynamyc link library

Have a good day
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900