Win32 files locked for reading: how to find out who#39;s locking them(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 文件被锁定以供阅读:如何找出谁在锁定它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Win32 文件被锁定以供阅读:如何找出谁在锁定它们
基础教程推荐
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 从 std::cin 读取密码 2021-01-01