Win32 文件被锁定以供阅读:如何找出谁在锁定它们 [英] Win32 files locked for reading: how to find out who's locking them

查看:19
本文介绍了Win32 文件被锁定以供阅读:如何找出谁在锁定它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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 文件被锁定以供阅读:如何找出谁在锁定它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆