?
Solved

How to detect a running session of IExplorer or Netscape

Posted on 1998-10-11
3
Medium Priority
?
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 total points
ID: 1439259
Yes,
  Add it as a module and then use the CheckForNetscapeOrIE()routine as needed.

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

801 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