I have memory mapped a file on disk as follow:
const wchar_t fileName = L"temp.txt"; HANDLE h = CreateFile(fileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); HANDLE fileMap = CreateFileMapping(h, NULL, PAGE_READWRITE, 0x0, 1024, NULL); char *ptr = (char *)MapViewOfFile(fileMap, FILE_MAP_WRITE | FILE_MAP_READ, 0, 0, 1024)
Is it possible to write to the same file by another process while it is memory mapped?
FILE *fp = fopen("temp.txt", "w+");
if(NULL == fp) printf("Failed to open\n");
Above code always prints 'Failed to open' if the file is memory mapped.