2012-09-26 28 views
0

我注意到,記事本可能需要很長時間來加載一個大的地方,它似乎完全沒有響應,但文件句柄似乎只在很短的時間內活動在開始時。一旦加載開始,另一個進程可以打開一個獨佔共享模式的文件,即使用值0作爲dwShareMode記事本風格加載的窗口上的大文件

記事本如何繼續使用封閉句柄或使用任何魔法進行加載?

+1

我感覺從若有所失的 –

+0

在哪裏的問題隱藏在你的帖子? –

+0

謝謝我添加了缺少的__ :) –

回答

0

沒關係我已經弄清楚了記事本的功能。這裏的sollution是否有人需要它:

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);