如何查找当前进程加载的文件路径

编程入门 行业动态 更新时间:2024-10-24 17:31:04
本文介绍了如何查找当前进程加载的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是一些代码:-

Here is some code:-

Static OldWindow As String Dim pr As Process, i As Integer ' add all running processes to collection for later use prc = New Collection For Each pr In Process.GetProcesses If pr.MainWindowTitle <> "" Then prc.Add(pr.MainWindowTitle) End If Next ' now find process with focus GetWindowThreadProcessId(GetForegroundWindow(), i) pr = Process.GetProcessById(i) Dim path As String = pr.MainWindowTitle If path <> OldWindow Then OldWindow = path RaiseEvent DocumentChanged(path) End If

我希望不要使用COM等来查找已加载文件的路径.

I was hoping not to use COM etc to find the path of the file loaded. Any ideas?

推荐答案

不清楚您要的是什么. 没有通用方法可以找出哪些应用程序已加载哪些文件.每个应用程序都是不同的,并且可能会也可能不会完全公开此信息.大多数都没有. 现在,如果您要查看进程当前打开了哪些文件(用于读取和/或写入,未加载"),那么您必须枚举该进程的句柄.这需要行政特权.您可以在此处 [ ^ ]. It''s not very clear what you''re asking for. There is no generic method to find out which applications have which files loaded. Every application is different and may or may not expose this information at all. Most don''t. Now, if you''re asking to see which files a process currently has open (for read and/or write, NOT "loaded"), then you have to enumerate the handles of the process. This requires administrative priv''s. You can read about what it takes to do this here[^].

更多推荐

如何查找当前进程加载的文件路径

本文发布于:2023-11-17 11:49:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609916.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   进程   加载   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!