Link to home
Start Free TrialLog in
Avatar of browndog
browndog

asked on

Is an app running?

Is there a simple way to tell if a Windows application is currently running - all I know is part of the name and the executable that would have been invoked?  I am using VB6 w/ SP3.  Thanks in advance.
Avatar of Erick37
Erick37
Flag of United States of America image

The API FindWindow would work is you know either the exact window's caption or the class name of the window.  Which application are you trying to find?
Avatar of browndog
browndog

ASKER

Trying to find out if Oracle's Discoverer 3.1 OLAP tool is running.  So FindWindow will do it if I know the exact caption?
Yes, if you know the exact caption of a normal window you can retrieve its handle.  e.g.

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub Command1_Click()
    Dim hWind As Long
    Dim sApp As String
    sApp = "Oracle's exact caption" '<-Exact caption of window
    hWind = FindWindow(vbNullString, sApp)
    If hWind <> 0 Then
        Debug.Print sApp & " is running"
    Else
        Debug.Print sApp & " is NOT running"
    End If
End Sub
If you know the name of the process, you can use this code to get the list of processes currently running on machine...

1) http://www.thescarms.com/vbasic/runningprocs.htm

2) http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4377

Use #2 with causion. Get rid of the kill code from there...

Hope this helps you...
ASKER CERTIFIED SOLUTION
Avatar of mcrider
mcrider

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks to all who offered answers.  I continue to think very highly of EE and you folks who are so open with your skills and time.  I'm accepting mcrider's answer as it allows a wildcard on the app name.

Browndog
Thanks for the points!

Cheers!