Microsoft Windows CE 3.0  

MapViewOfFile

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This function maps a view of a file into the address space of the calling process.

LPVOID MapViewOfFile( HANDLE
hFileMappingObject, 
DWORD
dwDesiredAccess, 
DWORD
dwFileOffsetHigh, 
DWORD
dwFileOffsetLow, 
DWORD
dwNumberOfBytesToMap
);

Parameters

hFileMappingObject
Handle to an open handle of a file-mapping object. The CreateFileMappingfunction returns this handle.
dwDesiredAccess
Specifies the type of access to the file view and, therefore, the protection of the pages mapped by the file. This parameter can be one of the following values:
Value Description
FILE_MAP_WRITE Read-write access. The hFileMappingObjectparameter must have been created with PAGE_READWRITE protection. A read-write view of the file is mapped.
FILE_MAP_READ Read-only access. The hFileMappingObjectparameter must have been created with PAGE_READWRITE or PAGE_READONLY protection. A read-only view of the file is mapped.
FILE_MAP_ALL_ACCESS Same as FILE_MAP_WRITE.
dwFileOffsetHigh
Specifies the high-order 32 bits of the file offset where mapping is to begin.
dwFileOffsetLow
Specifies the low-order 32 bits of the file offset where mapping is to begin. The combination of the high and low offsets must specify an offset within the file that matches the system's memory allocation granularity, or the function fails. That is, the offset must be a multiple of the allocation granularity. Use the GetSystemInfofunction, which fills in the members of a SYSTEM_INFOstructure, to obtain the system's memory allocation granularity.
dwNumberOfBytesToMap
Specifies the number of bytes of the file to map. If dwNumberOfBytesToMapis zero, the entire file is mapped.

Return Values

The starting address of the mapped view indicates success. NULL indicates failure. To get extended error information, call GetLastError.

Remarks

The 64 KB alignment is not required for the dwFileOffsetLowparameter.

Mapping a file makes the specified portion of the file visible in the address space of the calling process.

Multiple views of a file (or a file-mapping object and its mapped file) are said to be "coherent" if they contain identical data at a specified time. This occurs if the file views are derived from the same file-mapping object. In order to create another view of a file-mapping object for a different process, use the CreateFileMappingfunction.

A mapped view of a file is not guaranteed to be coherent with a file being accessed by the ReadFileor WriteFilefunction.

Note   To guard against an access violation, use structured exception handling to protect any code that writes to or reads from a memory mapped view.

Requirements

Runs On Versions Defined in Include Link to
Windows CE OS 1.01 and later Winbase.h   Coredll.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CreateFileMapping, GetSystemInfo, UnmapViewOfFile, SYSTEM_INFO