[DllImport("kernel32.dll", SetLastError=true)]
static extern bool QueryFullProcessImageName([In]IntPtr hProcess, [In]int dwFlags, [Out]StringBuilder lpExeName, ref int lpdwSize);
Declare Function QueryFullProcessImageName Lib "kernel32.dll" (TODO) As TODO
None.
System.Diagnostics.Process.MainModule.FileName
To query the filename for a process that is running elevated from a process that is not, the .NET api crashes.
This is a workaround.
Please add some!
int capacity = 1024;
StringBuilder sb = new StringBuilder(capacity);
IntPtr handle = OpenProcess(ProcessAccess.QueryLimitedInformation, false, process.Id);
QueryFullProcessImageName(handle, 0, sb, ref capacity);
string fullPath = sb.ToString(0, capacity);
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684919(v=vs.85).aspx