#include "stdafx.h" #include "windows.h" #include "iostream" #include "stdio.h" using namespace std; int main (int argc, _TCHAR* argv[]) { HANDLE src; src = CreateFile ( "C:\\work\\abc.dat", // pointer to name of the file GENERIC_READ | GENERIC_WRITE, // access (read-write) mode 0, // share mode NULL, // pointer to security attributes OPEN_ALWAYS, // how to create FILE_ATTRIBUTE_NORMAL, // file attributes NULL // handle to file with attributes to copy ); if (src == INVALID_HANDLE_VALUE) std::cout << "Nelze otevrit zdrojovy soubor" << std::endl; if (src != INVALID_HANDLE_VALUE) { std::cout << "Soubor otevren" << std::endl; HANDLE m; m = CreateFileMapping (src, // file handle NULL, // pointer to security attributes PAGE_READWRITE, // protection 0, // size high 16 * 1024, // size low NULL // mapping name ); if (m != NULL) { std::cout << "Zobrazeni vytvoreno" << std::endl; void * p; p = MapViewOfFile (m, // file mapping FILE_MAP_WRITE | FILE_MAP_READ, // access 0, // offset high 0, // offset low 8 * 1024 // length ); if (p != NULL) { std::cout << "View je pripraveno" << std::endl; char * c = (char *) p; *c = 'A'; c++; *c = 'B'; c++; *c = 'C'; UnmapViewOfFile (m); } CloseHandle (m); } CloseHandle (src); } std::cout << "Konec programu" << std::endl; char * str = new char [11]; std::cin.read(str, 10); return 0; }