| Under Windows CE, creating a memory mapped file is a little esoteric. Instead of just using CreateFile(), like you might expect, to open the file, one must use the Windows CE specific function, CreateFileForMapping(). Otherwise, it's pretty straightforward. |
| HANDLE hFile = 0
HANDLE hFileMap = 0;
PBYTE lpMem;
TCHAR szFileName[MAX_PATH];
// Get the file name
hFile = CreateFileForMapping(
szFileName,
GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, 0);
hFileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, 0);
lpMem = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0);
UnmapViewOfFile (lpMem);
CloseHandle (hFileMap);
CloseHandle (hFile);
|