Solved

How to detect a running session of IExplorer or Netscape

Posted on 1998-10-11
3
188 Views
Last Modified: 2010-04-30
I want to detect a running session of IExplorer or Netscape using VB4.0.
0
Comment
Question by:rfb
  • 2
3 Comments
 
LVL 2

Expert Comment

by:WDB
ID: 1439257
Use the EnumWindows Procedure

Option Explicit

Declare Function EnumWindows Lib "user32" (ByVal wndenmprc As Long, ByVal lParam As Long) As Long

Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Private Target As String
Private Target2 As String

' Check for a running app
Public Function EnumCallback(ByVal app_hWnd As Long, ByVal param As Long) As Long
Dim buf As String * 256
Dim title As String
Dim length As Long

    ' Get the window's title.
    length = GetWindowText(app_hWnd, buf, Len(buf))
    title = Left$(buf, length)

    ' See if this Window Is IE
    If InStr(title, Target1) <> 0 Then
         ' Internet Explorer is running
         ' Do What You Need To Do With It
    End If

    ' See if this Window Is Netscape
    If InStr(title, Target2) <> 0 Then
         ' Netscape Navigator is running
         ' Do What You Need To Do With It
    End If

    ' Continue searching.
    EnumCallback = 1
End Function
)
   
' Look For IE and Netscape.
Public Sub CheckForNetscapeOrIE()

    Target1 = "Internet Explorer"
    Target2 = "Netscape Navigator"

    EnumWindows AddressOf EnumCallback, 0
End Sub

0
 
LVL 1

Author Comment

by:rfb
ID: 1439258
WDB: Thanks...but I guess I'm a little "green". Where do I put this code. Do I add a module?. Can you please be more specific?
thanks
0
 
LVL 2

Accepted Solution

by:
WDB earned 50 total points
ID: 1439259
Yes,
  Add it as a module and then use the CheckForNetscapeOrIE()routine as needed.

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

776 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