Solved

How to detect a running session of IExplorer or Netscape

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 76
SLMGR Switches Are Not Working On KMS Host 3 114
How to Add / Edit Windows Menu 4 68
IF ELSE Statement in Excel Macro VBA 16 75
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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