HANDLE hfilemap;HANDLE hfile;char* pMap;hfile = CreateFile(L"My.txt", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);hfilemap = CreateFileMapping(hfile, 0, PAGE_READWRITE, 0, 256, L"MyFileMapping");pMap = static_cast<char*>(MapViewOfFile(hfilemap, FILE_MAP_ALL_ACCESS, 0, 0, 0));
STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); wchar_t name[] = L"..\\HelloWorld\\debug\\HelloWorld.exe"; WINBOOL wChild = CreateProcess(0, name, 0, 0, FALSE, 0, 0, 0, &si, &pi);
C++ (Qt)bool SharedIndexReader::open(const char *name){ mapFile = OpenFileMapping( FILE_MAP_READ, // Read access FALSE, // Do not inherit the name name // File mapping name ); if (!mapFile) return false; size = (index *)MapViewOfFile( mapFile, // Handle of the map object FILE_MAP_READ, // Read access 0, // High-order DWORD of the file offset 0, // Low-order DWORD of the file offset sizeof(*size) // The number of bytes to map to view ); return (size != nullptr);}