Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

How to detect a running session of IExplorer or Netscape

I want to detect a running session of IExplorer or Netscape using VB4.0.
0
rfb
Asked:
rfb
  • 2
1 Solution
 
WDBCommented:
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
 
rfbAuthor Commented:
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
 
WDBCommented:
Yes,
  Add it as a module and then use the CheckForNetscapeOrIE()routine as needed.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now