Solved

Sharing CStrings and CMapStringToString in a 32 bit dll

Posted on 1998-03-12
4
540 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
notReplace  challenge 53 151
sum28 challenge 31 117
post4 challenge 28 113
Problem to open Excel file 15 224
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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