views:

30

answers:

1

My application tried to scrape IE8, here we somehow obtain HANDLE to Internet Explorer Window/UI. Now I want to get the job handle for IE8. One Idea is to - Determine first the process id using the IE Window HANDLE using GetWindowThreadProcessId() but after this I am stuck.

There is new implementation in IE8, here every tab opened is a process within a job. Thus IE8 we see is managed as a job.

A: 

I couldn't find any documented way to get the job to which a process is bound; also, I couldn't find any documented way to enumerate all the jobs in the system, except the WMI way that however works only from XP onwards (which I don't think it's a problem since you're targeting IE8) and only with named jobs (which may actually be a problem if IE8 uses anonymous job objects).

If IE's jobs are in this list, then the road is downhill: just use OpenJobObject on each job name you can get (or, if you manage to narrow down your work with some heuristic on the job names, even better) and use the IsProcessInJob to check if your process handle (which you get with OpenProcess + GetWindowThreadProcessId) belongs to the job; once you get a match, you're set. Remember to close all those handles! :)

In the unfortunate event that the job objects used by IE8 are unnamed, then the whole thing becomes more difficult. You probably need to resort to almost-undocumented (by Microsoft, but widely documented on the net) handle-enumeration techniques to enumerate all the handles relative to your target process. You can then filter out just the job objects handles, and use the technique described above to get the right one.


By the way, why do you need to access the job objects used by IE8?

Matteo Italia
Unfortunately, IE8 uses unamed objects.I wil get name of process from process id. - To Figure OutThis will always be iexplore.exe and then enumerate all processes with same name so that they have same parent.Again need to get the latest process within all related processes - To Figure Out StillThanks for Reply
IE8 will launch every new tab as child process in this job. Even when one launches a new instance (when one is already open) will go as child process in this job.I want to scrap one of these child processes/tab ... to get that process id .. job details will be useful.I am though looking into ... another approach to solve this problem
Thank You for Inputs :)
You're welcome; if you think they were useful, please upvote my answer :) . By the way, I too think that getting the job object wouldn't help you in your task; exactly what do you mean for "scrap one of these child processes"?
Matteo Italia