Solved

How do I get process information about IE window

Posted on 2013-05-24
5
1,914 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Answered my own question
0

Featured Post

Backup Your Microsoft Windows Server®

Backup 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.

Join & Write a Comment

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now