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 文件被锁定以供阅读:如何找出谁在锁定它们


基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 常量变量在标题中不起作用 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01