Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sharing CStrings and CMapStringToString in a 32 bit dll

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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