on
DWORD dwMaximumSizeHigh, // high-order DWORD of size
DWORD dwMaximumSizeLow, // low-order DWORD of size
LPCTSTR lpName // object name
);
LPVOID MapViewOfFile(
HANDLE hFileMappingObject, // handle to file-mapping object
DWORD dwDesiredAccess, // access mode
DWORD dwFileOffsetHigh, // high-order DWORD of offset
DWORD dwFileOffsetLow, // low-order DWORD of offset
SIZE_T dwNumberOfBytesToMap // number of bytes to map
);
BOOL UnmapViewOfFile(
LPCVOID lpBaseAddress // starting address
);
Tips:
也可以尽量早地把对象关闭,以消除资源泄漏的可能性,如:
HANDLE hFile = CreateFile();
HANDLE hFileMapping = CreateFileMapping(hFile,);
CloseHandle(hFile);
PVOID pvFile = MapViewOfFile(hFileMapping,);
CloseHandle(hFileMapping);
// use the memory-mapped file.
UnmapViewOfFile(pvFile);