Solved

How to detect a running session of IExplorer or Netscape

Posted on 1998-10-11
3
185 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…

707 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

18 Experts available now in Live!

Get 1:1 Help Now