Solved

Sharing CStrings and CMapStringToString in a 32 bit dll

Posted on 1998-03-12
4
498 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
Comment Utility
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
Comment Utility
Correction: ReadProcessMemory copies the contents of the memory too.
0
 

Author Comment

by:AWF
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

12 Experts available now in Live!

Get 1:1 Help Now