Check for active app 
Author Message
 Check for active app

I want to check if a certain app is already running. How is that done?
So I want to start an app (with Shell-function) but before that I want to
see if the app is already running. I hope it's clear.
Any suggestions?
Thanks.


Sun, 06 Jul 2003 01:14:10 GMT  
 Check for active app

Quote:
> I want to check if a certain app is already running. How is that done?
> So I want to start an app (with Shell-function) but before that I want to
> see if the app is already running. I hope it's clear.
> Any suggestions?

If the app has a certain window title that doesn't change, then you
could always use the FindWindow API to see if it's open.

Regards, Otser.



Sun, 06 Jul 2003 06:59:50 GMT  
 Check for active app
If the App is written by yourself then you could use this :-

Note - you need to change the caption of the main form to its run time
caption *after* running this - if you are using App.PrevInst

Another method is to use the CreateMutex API

Option Explicit

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

Private Declare Function PostMessage _
                Lib "user32" Alias "PostMessageA" _
                (ByVal hwnd As Long, _
                 ByVal wMsg As Long, _
                 ByVal wParam As Long, _
                 lParam As Any) As Long

Private Declare Function ShowWindow _
                Lib "user32" _
                (ByVal hwnd As Long, _
                 ByVal nCmdShow As Long) As Long

Const SW_SHOWNORMAL = 1

Public Sub ActivateApp(Caption$, Er As Boolean)
    Dim WinWnd As Long

    Er = False
    'Search the window
    WinWnd = FindWindow(vbNullString, Caption)
    If WinWnd = 0 Then
       Er = True
       Exit Sub
    End If
    'Show the window
    ShowWindow WinWnd, SW_SHOWNORMAL
    ' ---
    On Error Resume Next
    AppActivate Caption$

End Sub

Quote:

>I want to check if a certain app is already running. How is that done?
>So I want to start an app (with Shell-function) but before that I want to
>see if the app is already running. I hope it's clear.
>Any suggestions?
>Thanks.



Sun, 06 Jul 2003 20:54:41 GMT  
 Check for active app
Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName as String, _
               ByVal lpWindowName As Long) As Long

I think you mean this function. But how find out the app's ClassName or the
app's WindowName? It's for Serv-U (ftp-server), maybe that helps.


Quote:

> > I want to check if a certain app is already running. How is that done?
> > So I want to start an app (with Shell-function) but before that I want
to
> > see if the app is already running. I hope it's clear.
> > Any suggestions?

> If the app has a certain window title that doesn't change, then you
> could always use the FindWindow API to see if it's open.

> Regards, Otser.



Sun, 06 Jul 2003 21:24:15 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Closing windows - check for active app

2. Active program: keeping the app active and checking time

3. Checking for Active Word App

4. Find out if my app is the active app

5. How to check if WordMail is active?

6. check active document

7. placing a checked logo in an active document

8. Checking for active internet connection.

9. Checking if an application is still active before sendkeys

10. checking if application is active

11. checking for existence of Active X object

12. NT4.0 and RAS, Checking for active connection

 

 
Powered by phpBB® Forum Software