none
ProcessId from ShDocVw.InternetExplorer RRS feed

All replies

  • Hi Biju,

    Thank you for posting here.

    Based on my search, I find ShDocVw.InternetExplorer in this link. It is a interface. As usual, the interface can not create an instance. Therefore, could you provide the related code about this? 

    If you want to get processId, you could look at the following link.

    https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.id?view=netframework-4.8

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 11, 2019 7:03 AM
    Moderator
  • Thank you Jack for your response on this.

    I am retrieving all the windows opened using the below code.

    foreach

    (SHDocVw.InternetExplorerie inshellWindows)

    {

         int mainWindowHandle=ie.HWND;

    }

    I am trying to retrieve the ProcessID of a tab in IE from the ie object  in the above code, similar to the below code.

    int processId=ie.ProcessID.

    Basically I am trying to find processId for all the IE Tabs opened using ShDocVw.InternetExplorer (ShDocVw.ShellWindows)

    Thanks

    Biju

    Tuesday, June 11, 2019 11:33 AM
  • Once you have an HWND you can use P/Invoke with GetWindowThreadProcessId
    Tuesday, June 11, 2019 11:46 AM
  • Hi RLWA32, thanks for supporting, but the ie.HWND is same for all the tabs, and I am not able to retrieve the processId for each tab. In this case it will be same for all the tabs

    Wednesday, June 12, 2019 4:43 AM
  • I don't think you're going to find a simple and convenient answer.  It's a bit old now, but take a look at https://blogs.msdn.microsoft.com/askie/2009/03/20/how-to-determine-which-ie-tabs-goes-to-which-iexplore-exe-process-when-using-internet-explorer-8/
    Wednesday, June 12, 2019 9:42 AM
  • I adapted the C++ code from Raymond Chen's blog at A big little program: Monitoring Internet Explorer and Explorer windows, part 1: Enumeration to accomplish your objective.

    The blog code already distinguishes between Internet Explorer windows and Explorer windows that are enumerated in the shell windows collection.  All I did was add a snippet to grab the processid from the HWNDs.

    For example, with 2 tabs open in IE (one on a blank page and the other at this site) and one explorer window open the code produced the following -

    HWND : 000B0334 Process id : 3236 Internet Explorer Location : https://social.msdn.microsoft.com/Forums/en-US/home
    HWND : 000F0202 Process id : 6060 Internet Explorer Location : about:blank
    HWND : 00080358 Process id : 2752 Explorer Location : F:\RLWA32

    You can see the IE process tree that agrees with the above -

    I'll leave the conversion of the C++ code to C# to someone else.


    • Edited by RLWA32 Wednesday, June 12, 2019 2:31 PM
    Wednesday, June 12, 2019 2:30 PM