Sharing Files and Memory
来源:互联网 发布:淘宝的差评怎么删除 编辑:程序博客网 时间:2024/05/02 02:14
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.
Related Topics
- Creating Named Shared Memory
- http://msdn.microsoft.com/en-us/library/aa366878(v=VS.85).aspx
- Sharing Files and Memory
- Sharing files between windows and linux
- Sharing Files
- Sharing Files
- Sharing Files Between Ubuntu Flash Drive and Windows
- Sharing Files between RHEL 6 and Windows Systems with Samba
- ZZ - Sharing files between Guest and Host Operating System
- Sharing Files with NFC
- Sharing Files笔记
- Sharing Memory—Automatically
- [转]Page Cache, the Affair Between Memory and Files
- Page Cache, the Affair Between Memory and Files
- Page Cache, the Affair Between Memory and Files
- Page Cache, the Affair Between Memory and Files
- android-sharing files with NFC
- ZZ - Mapping Pointers and Sharing Memory between Processes: Windows CE 5.0 vs. Windows Embedded CE 6.0
- memory-mapped files
- Memory-Mapped Files
- [ZZ]如何判断有向图是否成环
- 美国知名天使投资人列出愿投资的30大创意方向
- tcpdump丢包问题
- [ZZ]堆和栈的区别
- Puyo Game
- Sharing Files and Memory
- 0x80070422在hobocopy时碰到的错误
- RSA算法的分析与实现
- PetShop 4.0学习--介绍及安装
- flex中取得当前时间日期,计算时间间隔
- 使用虚拟机技术制作USB盘上操作系统
- openfiler 搭建虚拟存储 并 配置服务端
- RSA算法
- struts2 重复提交拦截器用法 token与token-session