If I know an windows handle, how can I find out the exe name and path (and the Process ID)of the application owning it?
Printable View
If I know an windows handle, how can I find out the exe name and path (and the Process ID)of the application owning it?
GetWindowThreadProcessId()
Can get the Process ID. Don't know how to leap from there to the exe name and path though unfortunately.
Roger
GetWindowModuleFileName()
You should call next functions:
1. Get WindowThreadProcessId(...) to get Process ID from HWND;
2. OpenProcess(...) or GetProcessInformation(...) to get HANDLE to the process;
3. EnumProcessModules(...) to get HANDLEs to all modules of the process;
4. GetModuleFileName(...) to get path to module's file.
Actually, I had the reverse problem. And I solved it.
I think this should work.
Thanks,
Ilgar Mashayev