本文介绍了如何查找当前进程加载的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一些代码:-
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[^].
更多推荐
如何查找当前进程加载的文件路径
发布评论