If i got the a handle to a specific windows
could i know the exe file path ???

infact i am making a program that need to close all windows opened by IEXPLORE.EXE before being run.

i am thinking this way .

call Api EnumWindows
which return handle to all opened windows .

then i use this handle to close the windows by sending WM_CLOSE message to it.

but the problem now, how to find Only iexplore windows from all the returned handles ?

btw , if you have another way , method plz tell me .

Thanks for your time.
Posted on 2002-05-23 14:29:48 by Sa6ry
you can use GetWindowThreadProcessId to get the ID of the process I don't know if there is a way of converting this ID to a path or not but if you use Process32First/Next you can find the paths of all running processes and if any of them match your window's process ID then u know to close it.
Posted on 2002-05-23 14:52:45 by Kudos
first of, get the process id of iexplorer.exe with toolhelp32 apis...as iexplorer can run in multi-instance make sure u get all iexplorer.exe processes runing and store them in some buffer.
then use GetWindowThreadProcessId with each window handle and compare the result with the PIDs u stored in the buffer to see if they belong or not to iexplorer.

Posted on 2002-05-23 14:52:53 by DZA
your method is a good one.

1: invoke enumerate

2: in your enumeration callback procedure you invoke GetClassName for each enumeration(use the handle)
3: then compare the class name you get to IEFRAME (IEFRAME is th internet explorer class name)
4: if equal send wm_close. if not equal do nothing

this is a tested method and works well.
Posted on 2002-05-23 14:53:03 by smurf
thanks all i have managed to make it :grin:

i made it as Kudos said . as i think this way is more general . as you can close any windows knowing it's file path ..

thank you alllllllll i am happy :))

Posted on 2002-05-24 04:53:42 by Sa6ry