Solved

Sharing CStrings and CMapStringToString in a 32 bit dll

Posted on 1998-03-12
4
511 Views
Last Modified: 2013-11-19
I need to convert a dll that was writtin for 16bit Windows. It made use of the CString and CMapStringToString classes to hold an undefined number of dynamically created strings and shared those strings (and the CStringMap) between different executables.

Does anyone know how I can share the memory allocated by these objects, between different exes, in the 32bit world?
0
Comment
Question by:AWF
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
stefanr earned 200 total points
ID: 1316953
There is no easy way to share memory in the 32bit world. There is some ways though. You could use Memory Mapped Files (CreateFileMapping, OpenFileMapping, MapViewOfFile, UnmapViewOfFile). You could use a common DLL with a shared data segment (#pragma data_seg, not recommended though). A Named Pipe could be an alternative (or TCP/IP, NetBios, etc, if you prefer). Or the most difficult of all, ReadProcessMemory. I recommend reading "Advanced Windows" by Jeffrey Richter. He have excellent examples of most of these methods.

In any way, it seems that you by some means have to copy the contents of the memory in one process to the other (with the exception of ReadProcessMemory).

/Stefan
0
 
LVL 3

Expert Comment

by:stefanr
ID: 1316954
Correction: ReadProcessMemory copies the contents of the memory too.
0
 

Author Comment

by:AWF
ID: 1316955
Thankyou for your response. I was afraid it wasnt going to be easy! Would an alternative be to write an out of process COM server? My understanding is that this would be perfrom quite slowly though
0
 
LVL 3

Expert Comment

by:stefanr
ID: 1316956
Personally I wouldn't worry so much about the performance as what parameters I am allowed to use when calling a DCOM server. Basically a DCOM server uses RPC which, by the way, is another way to share data between processes, even on other computers. However, you have to learn to use the MIDL compiler, and write .IDL files to use it. Using RPC would allow you to use any parameter for your functions, contrary to DCOM. You could easily fall into some traps (causing memory access violations, for example) if you are not careful with those parameters, though.

/Stefan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 123
ODBC Connection Logging, ADO.NET 6 55
ASCII Non-Printable characters/codes and their HTML equivalents 6 104
FizzBuzz challenge 9 76
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now