Posted March 1, 201411 yr hello tuts4you i suppose after mapping a file in memory, and after making a change/patch in this mapped memory, i need to save the bytes wich are changed using FlushViewOfFile , right? so the weird thing is, it saves the patch already without using the FlushViewOfFile api yet! so actually i don't have to use FlushViewOfFile because the bytes are automatic saved after unmapping it seems. can someone tell me why? hOpenFile = CreateFile(szFilePath, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL) hOpenFileMapping = CreateFileMapping(hOpenFile, NULL, PAGE_READWRITE, 0, dwSizeOfFile, NULL) pFile = MapViewOfFile(hOpenFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, dwSizeOfFile) /** make a some patches in mapped file, then unmap it **/ UnmapViewOfFile(pFile); CloseHandle(hOpenFileMapping); CloseHandle(hOpenFile); Edited March 1, 201411 yr by PieterJones
March 1, 201411 yr i suppose after mapping a file in memory, and after making a change/patch in this mapped memory, i need to save the bytes wich are changed using FlushViewOfFile , right?Nope, you don't. Closing file handle commits all changes automagically. FlushViewOfFile is useful in specific situations when, for example, you have the same file mapped in several processes and you want to write the changes without actually closing the handle. Something like this, for example - http://stackoverflow.com/questions/4306157/createfilemapping-synchronous-between-programs
Create an account or sign in to comment