|
Creating a File View
To map the data from a file to the virtual memory of a process, you must
create a view of the file. The MapViewOfFile and MapViewOfFileEx functions use the file-mapping object handle returned by CreateFileMapping to create a view of the file or a portion of the file in the process's virtual
address space. These functions fail if the access flags conflict with those
specified when CreateFileMapping created the file-mapping object.
The MapViewOfFile function returns a pointer to the file view. By dereferencing a pointer in
the range of addresses specified in MapViewOfFile, an application can read data from the file and write data to the file.
Writing to the file view results in changes to the file-mapping object. The actual
writing to the file on disk is handled by the system. Data is not actually
transferred at the time the file-mapping object is written to. Instead, much of the
file input and output (I/O) is cached to improve general system performance.
Applications can override this behavior by calling the FlushViewOfFile function to force the system to perform disk transactions immediately.
The MapViewOfFileEx function works exactly like the MapViewOfFile function except that it allows a process to specify the base address of the
view of the file in the process's virtual address space in the lpvBase parameter. If there is not enough space at the specified address, the call
fails. Therefore, if you must map a file to the same address in multiple
processes, the processes should negotiate an appropriate address.
Windows NT: The lpvBase parameter must be an integral multiple of the system memory allocation
granularity or the call fails. To obtain the system's memory allocation granularity,
use the GetSystemInfo function, which fills in the members of a SYSTEM_INFO structure.
Windows 95: Under Windows 95, the address is rounded down to the nearest integral
multiple of the system's memory allocation granularity. For subsequent file views, if
the address specified does not match the address to which Windows 95 mapped the
file view, MapViewOfFileEx fails.
An application can create multiple file views from the same file-mapping
object. A file view can be a different size than the file-mapping object from which
it is derived, but it must be smaller than the file-mapping object. The offset
specified by the dwOffsetHigh and dwOffsetLow parameters of MapViewOfFile must be a multiple of the allocation granularity of the system.
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|