在 C++(特别是 Visual C++)中,有时您无法打开文件,因为另一个可执行文件已将其打开且未共享以供读取.如果我尝试打开这样的文件,我如何以编程方式找出谁锁定了该文件?
In C++ (specifically on Visual C++), sometimes you cannot open a file because another executable has it opened and is not sharing it for reads. If I try to open such a file, how can I programatically find out who's locking the file?
在 Windows 2000 及更高版本中,如果不使用内核模式驱动程序,则无法执行此操作.Process Explorer 和其他类似工具会自动加载驱动程序来完成此操作.这是因为文件句柄位于内核空间中,用户模式应用程序(EXE 文件)无法访问.
In Windows 2000 and higher, you cannot do this without using a kernel-mode driver. Process Explorer and other similar tools load a driver automatically to accomplish this. This is because the file handles are in kernel space and not accessible by user-mode applications (EXE files).
如果您真的对此感兴趣,请查看this项目.
If you are really interested in doing this, take a look at this project.
这篇关于Win32 文件被锁定以供阅读:如何找出谁在锁定它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!