How do retrieve the path of a File open in a foreign process ?
Thank you.
Printable View
How do retrieve the path of a File open in a foreign process ?
Thank you.
Welcome to the forums. :wave:
:confused: What do you mean by "foreign process"?
Quote:
Originally Posted by Hack
I mean a running application . It could be Word, Excel, NotePad ...
However, I do not want to use Automation for this as not every application supports it.
Thanks.
To get the file path you can use the mainmodule property of the process class. I used winamp in the example. Note that GetProcessesByName creates an array and populates it. An array, because there can be more than one processes with the same name - like 3 notepad windows.
VB Code:
Dim Proc As Process() = Process.GetProcessesByName("winamp") lbl1.Text = Proc(0).MainModule.FileName
EDIT: Upsss, I noticed too late it is the API section. Still, you can do it this way without API calls.
Is this what you mean?