Getting process ID of a SHDocVw.InternetExplorer spawned IE8 process
I'm using SHDocVw.InternetExplorer to launch IE in my code. In certain cases I开发者_开发问答nternetExplorer.Quit() doesn't work. I have tried several things to make Quit work but without success. I'm now resorting to Process.Kill.
Now if a manually launched instance of IE8 is already running when SHDocVw.InternetExplorer is used to launch another one the new one gets created as a child process of the existing IE:
The SHDocVw.InternetExplorer IE is process id 996 on the screenshot, the manually launched one is 3388 plus its child 2876.
Now if I use InternetExplorer.HWND to retrieve the window handle of my IE and then GetWindowThreadProcessId to get the process ID I end up with 3388, the parent IE process ID when what I want is 996, the InternetExplorer.HWND launched IE process ID.
I'm not sure on which step it gets wrong.
Should I be retrieving the HWND in a different way or the process ID? Or both?Thanks!
Edit: I've just tried sending WM_CLOSE
to the HWND and it closed the parent IE. I suppose it means I'm getting a wrong HWND?
Edit: It may be worth noting that only the manually launched IE is visible when I do the closing. Would this mean I'm getting the HWND of the only visible IE therefore?
精彩评论