Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sharing CStrings and CMapStringToString in a 32 bit dll

Posted on 1998-03-12
4
Medium Priority
?
579 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

916 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