使用文件识别进程

发布于 2024-07-10 18:25:32 字数 145 浏览 5 评论 0原文

我一直在试图弄清楚如何以编程方式识别锁定特定文件的进程。 我已经搜索了 Win32 API 和 WMI,但到目前为止我找不到任何东西。 我知道这是可能的 - Sysinternals 能够列出系统上每个进程访问/锁定的每个资源。

有人能给我提示吗?

I have been trying to figure out how to programmatically identify the process that has a lock on a particular file. I've searched through the Win32 API and WMI, but so far I can't find anything. I know it's possible - Sysinternals is able to list every resource accessed/locked by every process on the system.

Can anyone drop me a hint?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

乱了心跳 2024-07-17 18:25:33

您可以使用Sysinternals 中的handle.exe

类似于:

> handle /accepteula C:\path\to\directory
...
program.exe           pid: 1234   type: File           2E4: C:\path\to\directory
...

感谢 https://stackoverflow.com/a/599268/367916

You can use handle.exe from Sysinternals.

Something like:

> handle /accepteula C:\path\to\directory
...
program.exe           pid: 1234   type: File           2E4: C:\path\to\directory
...

Thanks to https://stackoverflow.com/a/599268/367916 .

星軌x 2024-07-17 18:25:33

中的 Process Explorer

  1. 您可以使用 Microsoft Download & 打开包装并 运行Process Explorer
  2. 单击查找菜单,然后单击查找句柄或DLL...或按CTRL + F
  3. 复制并将路径粘贴到文件的锁定文件夹
  4. 单击搜索,您可以从Process Explorer主窗口终止进程

You could use Process Explorer from Microsoft

  1. Download & unpack & run Process Explorer
  2. Click Find menu and then click Find Handle or DLL... or press CTRL + F
  3. Copy and paste path to locked folder of file
  4. Click Search, you can kill process from main Process Explorer window
玩物 2024-07-17 18:25:33

如果您可以限制自己使用足够新的 Windows 版本,重新启动管理器可以告诉您 哪个进程打开了特定文件

If you can limit yourself to new enough versions of Windows, the Restart Manager can tell you which process has a particular file open.

驱逐舰岛风号 2024-07-17 18:25:33

由于 Process Explorer 的工作方式,我怀疑您需要寻找的是一种查找附加到给定进程的文件句柄的方法,并且您必须为系统中的每个进程提取该列表并查找你的文件在里面。

Because of the way Process Explorer works, I suspect that what you need to look for is a way of finding the file handles attached to a given process, and that you'll have to pull that list for each process in the system and look for your file within it.

女皇必胜 2024-07-17 18:25:33

我不知道在 Windows 中,但有人可能会发现知道在 Linux 中有用,您可以使用 lsof 命令,或者只是搜索文件夹 /proc/PROCESS_ID/fd 并查看哪个进程已打开文件。

I don't know in Windows, but somebody might find useful to know that, in Linux, you can use the lsof command, or just search through the folders /proc/PROCESS_ID/fd and see what process has opened the file.

一曲琵琶半遮面シ 2024-07-17 18:25:33

WhoLockMe 是一个不错的右键 Windows 资源管理器扩展。

WhoLockMe is a nice right click windows explorer extension.

虫児飞 2024-07-17 18:25:33

这篇文章可能对您有帮助。

看来您被迫使用 ntdll.dll 中未记录的函数来搜索系统上每个进程的文件列表。

This article might be helpful to you.

It appears you are forced to search through the list of files for each process on the system using undocumented functions in ntdll.dll.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文