//using System;
//using System.Runtime.InteropServices;
//using System.Text;
private const int MAX_PATH = 260;
private const int PROCESS_QUERY_INFORMATION = 0x400;
private const int PROCESS_VM_READ = 0x10;
[DllImport("user32", SetLastError = true)]
private static extern int GetWindowThreadProcessId(IntPtr hWnd, ref int lpdwProcessId);
[DllImport("kernel32", SetLastError = true)]
private static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32", SetLastError = true)]
private static extern bool CloseHandle(IntPtr hObject);
[DllImport("psapi", SetLastError = true)]
private static extern int GetModuleFileNameEx(IntPtr hProcess, IntPtr hModules, StringBuilder lpFileName, int nSize);
private static string GetExeFilePathFromHandle(IntPtr Handle) {
StringBuilder Buffer = new StringBuilder(MAX_PATH);
int Pid = 0x0;
IntPtr hProcess = IntPtr.Zero;
GetWindowThreadProcessId(Handle, ref Pid);
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, Pid);
Buffer.Length = GetModuleFileNameEx(hProcess, IntPtr.Zero, Buffer, MAX_PATH);
CloseHandle(hProcess);
return Buffer.ToString();
}