- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi to everybody. I am currently working on two different programs. The main program calls the other .exe program that computes some things and export data to .txt files. When the second program ends the main program continues and read data from the .txt files. I'm wondering if there's any possibility of the main program access directly the memory address of where data computed from the second programs are, instead of reading it from .txt files. Sometimes the main programs spent a lot a time reading and writing .txt files! Note that main program and the other program are separated .exe files.
I apreciate all the help you can provide to me!
Gratefully,
Pedro Santos
I apreciate all the help you can provide to me!
Gratefully,
Pedro Santos
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The different EXEs are in different address spaces, so you can't just pass the address. But you can share data between two programs through a DLL - see the provided sample DLL\DLL_Shared_Data for an example.
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The different EXEs are in different address spaces, so you can't just pass the address. But you can share data between two programs through a DLL - see the provided sample DLL\DLL_Shared_Data for an example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for the answer Steve. I explored the sample program and I found that it does exactly what I need.
Gratefully,
Pedro Santos
Gratefully,
Pedro Santos
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Steve. I'm trying to use the dll to share data between my two programs and I almost achieved what I need. Despite of this, I'm having trouble sharing allocatable arrays because I can't initialize them to a non-zero value before they are allocated. Because of this no data is shared between programs thought this allocatable arrays. I also tried static arrays (example A(100)) and they worked fine. Is there any way to use allocatable array or I will be forced to change to static arrays? I appreciate all the help you can gave to me.
Gratefully,
Pedro Santos
Gratefully,
Pedro Santos
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why not just combine the two programs and use module variables to store shared data? You might also keep the output text files as a check on the data you are sharing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can't share allocatable arrays in this fashion. The static arrays work because the memory is allocated in the DLL and each of the executables map to it. The closest thing you can accomplish with dynamic allocation is to use the file mapping functions of Windows, but you would then have to use pointers to reference the data and this is somewhat complicated to set up.
You might also consider using other forms of interprocess communication, such as pipes, or even reconsider whether separate executables are really appropriate here. Perhaps a multithreaded approach would be suitable?
You might also consider using other forms of interprocess communication, such as pipes, or even reconsider whether separate executables are really appropriate here. Perhaps a multithreaded approach would be suitable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the reply. Yes I need to keep separated executables. I will investigate deeper your suggestions but it's almost certain that I will use the dll module to share data using static allocation. This method is very easy to implement and is capable of a significant speed up. I run a few test and I became very interested in the speed up that I achieved. Read and Write to files is really a time cost operation. Thank you Steve for the precious help you gave to me (one more time). This forum is really helpful.
Gratefully,
Pedro Santos
Gratefully,
Pedro Santos
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page