在另一个程序锁定文件时读取文件

Read a file while another program locked it

我有一个程序可以读取软件编写的文件。但是软件在写入文件时锁定了文件(我什至无法复制文件!)。如何在写入文件时读取文件?

我正在使用 Windows 7 和 NTFS 文件系统,我的程序是用 C++ 编写的。

写入文件的程序应该打开它并启用读取共享,否则其他进程无法从尚未关闭的文件中读取:

FILE_SHARE_READ

Enables subsequent open operations on a file or device to request read access.
Otherwise, other processes cannot open the file or device if they request read access.
If this flag is not specified, but the file or device has been opened for read access, the function fails.

MSDN CreateFile 中查看更多详细信息。