Re: How to share object between processes?
christophepichaud_at_hotmail.com
Date: 11/02/04
- Next message: Jeff F: "Re: Event after Dialog Launches"
- Previous message: Kevin: "system calls"
- In reply to: Jonghyun. Yoon \(À±Á¾Çö\): "How to share object between processes?"
- Next in thread: Scott McPhillips [MVP]: "Re: How to share object between processes?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 2 Nov 2004 18:51:14 +0100
Sharing objects between processes can be handled using named kernel object.
J.Richter described it in some Ms Press Books.
You can also check MSDN library with queries like "MapViewOfFile" or
"MapViewOfFile CreateFileMapping"
Check also articles like
- "Visual C++ 6.0 Technical Articles-Developing Optimized Code with
Microsoft Visual C++ 6.0"
- "Memory Technical Articles - Managing Memory-Mapped Files in Win32"
Look also at Platform SDK - Storage
Look at the overview sections:
<<
Sharing Files and Memory
File mapping can be used to share a file or memory between two or more
processes. To share a file or memory, all of the processes must use the name
or the handle of the same file mapping object.
To share a file, the first process creates or opens a file by using the
CreateFile function. Next, it creates a file mapping object by using the
CreateFileMapping function, specifying the file handle and a name for the
file mapping object. The names of event, semaphore, mutex, waitable timer,
job, and file mapping objects share the same name space. Therefore, the
CreateFileMapping and OpenFileMapping functions fail if they specify a name
that is in use by an object of another type.
To share memory that is not associated with a file, a process must use the
CreateFileMapping function and specify INVALID_HANDLE_VALUE as the hFile
parameter instead of an existing file handle. The corresponding file mapping
object accesses memory backed by the system paging file. You must specify a
size greater than zero when you specify an hFile of INVALID_HANDLE_VALUE in
a call to CreateFileMapping.
The easiest way for other processes to obtain a handle of the file mapping
object created by the first process is to use the OpenFileMapping function
and specify the object's name. This is referred to as named shared memory.
If the file mapping object does not have a name, the process must obtain a
handle to it through inheritance or duplication. For more information on
inheritance and duplication, see Inheritance.
Processes that share files or memory must create file views by using the
MapViewOfFile or MapViewOfFileEx function. They must coordinate their access
using semaphores, mutexes, events, or some other mutual exclusion technique.
For more information, see Synchronization.
A shared file mapping object will not be destroyed until all processes that
use it close their handles to it by using the CloseHandle function.
For information about file mapping object security, see File Mapping
Security and Access Rights.
>>
Regards,
Christophe Pichaud
CPi21 LLC
http://www.pichaud.com
"Jonghyun. Yoon (À±Á¾Çö)" <lucifer@nownuri.net> wrote in message
news:e7vtgoPwEHA.3416@TK2MSFTNGP09.phx.gbl...
> Hi.
>
> I want to share object between processes using memory map files.
> This object have several other object. (CMap, CList, CString, etc.)
> Thus, size of that class is dynamic.
>
> How can I share object between processes? plz. ¤Ð.¤Ð
>
>
- Next message: Jeff F: "Re: Event after Dialog Launches"
- Previous message: Kevin: "system calls"
- In reply to: Jonghyun. Yoon \(À±Á¾Çö\): "How to share object between processes?"
- Next in thread: Scott McPhillips [MVP]: "Re: How to share object between processes?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|