在Windows上的大文件的记事本样式加载

时间:2012-09-26 05:31:30

标签: windows file-io notepad file-locking

我注意到记事本可能需要很长时间来加载一个看起来完全没有响应的大片,但文件句柄似乎只在开始时很短的时间内处于活动状态。加载开始后,另一个进程可以打开一个独占共享模式的文件,即使用dwShareMode的值0

记事本如何继续使用闭合手柄或其使用的任何魔法进行加载?

1 个答案:

答案 0 :(得分:0)

没关系我已经知道记事本的作用了。如果其他人需要,这是解决方案:

hFile = CreateFile("file", 0x80000000, 3, NULL, 3, 0x80, NULL);
hMap = CreateFileMapping(hFile, NULL, 2, sizeHigh, sizeLow, NULL);
ptr = MapViewOfFile(hMap, 4, 0, 0, size);
CloseHandle(hMap);
CloseHandle(hFile);

/* At this point the handles are closed so programs that try
   to get share exclusive on the file succeed but I still have
   a pointer for reading the memory myself */ 

UnmapViewOfFile(ptr);
相关问题