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.