Solved

How do I get process information about IE window

Posted on 2013-05-24
5
1,981 Views
Last Modified: 2013-06-16
I am using the vb.net code below to find an instance of IE that is displaying a particular URL.

How can I also get the process information? If I could get the process ID then I could find the process. Thanks.

Dim window As SHDocVw.InternetExplorer
SA = CreateObject("Shell.Application")
            Dim windowCount As Integer = SA.windows().count()
            For Each window In SA.windows()
                Dim WindowURL = window.LocationURL
                logmessage("check windowURL = " & WindowURL)
                If InStr(WindowURL, URLToCheck) > 0 Then
                    logleave("IsWebTopPageOpen:success")
                    Return window
                End If
            Next
0
Comment
Question by:cschene
  • 3
5 Comments
 
LVL 47

Expert Comment

by:dlethe
ID: 39195885
try this
http://powertoe.wordpress.com/2010/11/10/finding-the-thread-pid-that-belongs-to-a-tab-in-ie-8-with-powershell/

Granted it is powershell, but you can always do this from VBS and trap/process the output

But I'm not 100% sure that javascript doesn't allow the same process ID to have more than one window, so this may not even be possible in the first place.
0
 

Author Comment

by:cschene
ID: 39195900
Thanks but I can't user PS as I am running ie7 on an XP machine.

This is vb.net code, BTW.

I am pretty sure that if I get a window handle that there is a way to get the process id from the window handle....just not sure exactly how
0
 
LVL 4

Expert Comment

by:Tushar_Darwatkar
ID: 39200425
Hello,

Did you tried using "Process Explorer v15.3" to track the process. If no please try installing it from below link ans share your experience.

http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
0
 

Accepted Solution

by:
cschene earned 0 total points
ID: 39211665
This is the code I used to get the process information from the window handle.  Per my original question I was using vb.net: I needed something programmatic in vb.net. I answered my own question.

'Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, ByRef lpdwProcessId As Long) As Long
    Private Declare Function GetWindowThreadProcessId Lib "user32" _
  (ByVal hwnd As IntPtr, _
    ByRef lpdwProcessId As Long) As Long
    Public Function getProcessFromWindowHandle(ByVal hWnd As Long) As Process

        Dim myProcess As Process = Nothing
        logenter("getProcessIDFromWindowHandle " & hWnd)
        Try
            Dim lngPid As Integer
            Dim lngAccessHwnd As IntPtr = New IntPtr(hWnd)
            GetWindowThreadProcessId(lngAccessHwnd, lngPid)
            ' GetWindowThreadProcessId(lngAccessHwnd, myProcessidPtr)
            myProcess = Process.GetProcessById(lngPid)
        Catch ex As Exception
            logmessage(ex.ToString())
            myProcess = Nothing
        Finally
            logleave("getProcessIDFromWindowHandle")
        End Try
        Return myProcess
    End Function
0
 

Author Closing Comment

by:cschene
ID: 39251085
Answered my own question
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Internet is a big network which is formed by connecting multiple small networks.It is a platform for all the users which are connected to it.Internet act as platform in different fields. Such as: Internet  as a collaboration platform. Internet  as…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question