MapViewOfFile failes with errorCode 6 (Invalid Handle)

后端 未结 1 920
醉梦人生
醉梦人生 2021-01-17 06:29

Im trying to map the file to the memory and use MapViewOfFile(), but it failes with error code 6. I tried just about anything, I also read about big files being the problem,

相关标签:
1条回答
  • 2021-01-17 07:30

    Here:

    HANDLE hFile = CreateFile(pFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

    Replace GENERIC_READ with GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE

    Also there is no FILE_MAP_ACCESS, but FILE_MAP_ALL_ACCESS.

    I tried this code and it maps test file with success, not sure what you want to do with it further. Also for inspecting problems you can also use: Procmon.exe from sysinternals - it will report you what problems occured during file manipulations.

    0 讨论(0)
提交回复
热议问题