Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 2.1 KB

MapViewOfFile.md

File metadata and controls

75 lines (50 loc) · 2.1 KB

Home

Function name : MapViewOfFile

Group: File Mapping - Library: kernel32


The MapViewOfFile function maps a view of a file mapping into the address space of the calling process.


Code examples:

Using File Mapping for enumerating files opened by Visual FoxPro
Using shared memory to exchange data between applications (processes)

Declaration:

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

FoxPro declaration:

DECLARE LONG MapViewOfFile IN kernel32;
	INTEGER hFileMappingObject,;
	INTEGER dwDesiredAccess,;
	LONG    dwFileOffsetHi,;
	LONG    dwFileOffsetLo,;
	LONG    dwNumberOfBytesToMap
  

Parameters:

hFileMappingObject [in] Handle to an open handle of a file mapping object. The CreateFileMapping and OpenFileMapping functions return this handle.

dwDesiredAccess [in] Type of access to the file mapping object, and therefore, the protection of the pages.

dwFileOffsetHigh [in] High-order DWORD of the file offset where the view is to begin.

dwFileOffsetLow [in] Low-order DWORD of the file offset where the view is to begin.

dwNumberOfBytesToMap [in] Number of bytes of the file mapping to map to the view.


Return value:

If the function succeeds, the return value is the starting address of the mapped view.


Comments:

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

For files that are larger than your address space, you can only map a small portion of the file data at a time. When you are through with the first view, then you unmap it and map a new view.

See also: MapViewOfFileEx, OpenFileMapping, UnmapViewOfFile.