|
|
Comments and Discussions
|
|
 |

|
It works great on WIndows2000/XP, but on Windows98, sometimes, I mean seldom, the shared memory gets trespassed by other process, or say that the memory contents get altered with no valid reason. For example, I have process A and process B using the shared memory, none of them did any change to the shared memory, but after a while some of the memory contents get modified mystically.
This never happened on Windows 2000/XP, but did from time to time on Windows9x. My 2c, do not use system page file, use a private disk file instead, to do so, give a valid file handle value to the first parameter of "CreateFileMapping".
|
|
|
|

|
Hello,
Is there any way to use CArchive with this class? It would be slick to be able to Serialize data in in one process and Serialize it out in another.
Ted
|
|
|
|

|
I have not compile it myself,sorry!
Please pardon my weak English!
|
|
|
|

|
Hiyah from Sydney, Australia
this looks great, but Im having trouble compiling with it - I get C2501 'missing storage class or type specifiers' for each of the 'CSemaphore *m_pSync' and 'CSingleLock *m_pLock' declarations in SharedMemory.h (and it goes downhill from there)
My guess would be that I need to tell MFC to include Multithreaded support (I would likely do the same if I was on my other dev platform, Sun Solaris) .. but Im not sure what this means on MFC ...
does it mean that I have to :-
1) #include <afxmt.h>
2) (where ??) StdAfx.h ???
sorry, thats probably a real basic question, maybe by the time Ive spent some time tomorrow (Saturday) on it, I'll have the answer myself ... (just need some backup/reassurance )
ps ... (1) #include <afxmt.h> was gleaned from a quick web-scan .. I'll post back here when Ive tried it - one of the problems with where I live is, its GMT +10. This is well ahead of most of you in the USA, so I like to try and get questions out there early, so as maybe by the next day I'll have answers ...
Thanks for a great job in the classes, Im learning a lot here ..
Garth
|
|
|
|

|
It's great that you have a callback in your constructor to initialize the memory at allocation time. You might want to make this callback more C++ friendly either by adding a "user parameter" (an opaque void *) that is passed to the callback. That way, if my CFoo class is creating the shared memory, I can do this:
void CFoo::MakeMemory()
{
CSharedMemory* pNewBlock = new CSharedMemory("name", 1024, CFoo::Initializer, this);
}
void CFoo::Initializeer(CSharedMemory* pMem, void* p)
{
CFoo* This = (CFoo*) p;
}
Alternatively, if you want to go the "real" OO C++ route, you can make the callback a functor.
--
Tim Lesher
http://www.lesher.ws
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Share variables in the shared memory across processes
| Type | Article |
| Licence | |
| First Posted | 6 Nov 2001 |
| Views | 140,051 |
| Downloads | 3,926 |
| Bookmarked | 76 times |
|
|