Unit E_MemMap

Classes

TEFileMap - map to a file
TEMemMap - Map to memory

Functions

Types

Constants

hMemMap

Variables


Functions


Types


Constants

hMemMap = $FFFFFFFF

This Unit implements an interface to Win32 memory mapped files. It can be used to map data simply residing in memory or data residing in a file. The data can be fully mapped into the processes address space or chunks can be mapped. It also provides capabilities for processes to synchronize via mutexes. When mapping sections of the memory, you must be aware that the Win32 memory mapped file interface requires that when you are requesting an offset into the memory region, this offset must be a multiple of the system's memory allocation granularity (I've called it PageSize). At this point it is 64K. This is not a concern when you are mapping anything less than 64K. However, to map anything > 64K the total memory size mapped must be a multiple of 64K or you will not have access to the memorysize MOD 64K bytes left over. Basically there are five rules to be successful when using these routines: 1. Mapname must be unique for each different case you use these objects (MyMap1 for case 1, MyMap2 for case 2 etc.).However, each process using the same memory map MUST use the same MapName. 2. Call MapExisting before CreateMemMap or FCreateMemMap. If another process has already started the mapping, all you want to do is map to the existing map. ie. If NOT MapExisting then CreateMemMap. 3. If your processes are going to write to the mapped memory, it is suggested you use the mutex stuff. 4. Pay heed to the warning above concerning seeking offsets into the mapped memory. Whenever you call the seek function, always check for an error. Errors in mapping to the file will result in the Memmap pointer being Nil. 5. You MUST call LeaveCriticalSection after calling EnterCriticalSection or you will lock other processes wishing to use the map into an infinite wait state. Always use a Try..Finally block.

Variables