Click to See Complete Forum and Search --> : Howto: from HWND to EXE ???


kalle
May 7th, 1999, 05:52 AM
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?

Roger Osborn
May 7th, 1999, 08:22 AM
GetWindowThreadProcessId()

Can get the Process ID. Don't know how to leap from there to the exe name and path though unfortunately.


Roger

BrianOG
May 10th, 1999, 05:11 AM
GetWindowModuleFileName()

ilgar
May 11th, 1999, 12:27 AM
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