Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

See if process is running?

Status
Not open for further replies.

robdunfey

Technical User
Apr 26, 2002
110
0
0
GB
Hi,

I am using visual basic 6. I want see if an application is running. i.i is notepad.exe running on the same PC as my VB app? I thought this would be straight forward but it seems I have to use the winapi? I have had a look around the net and have failed to find anything straight forward. I can't believe it is all that difficult, can anyone point me in the right direction?

Kind Regards, all help much appreciated,

Rob
 
If you do a keyword search in this forum for 'process', you will find several threads on this topic.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As Long) As Long

Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Dim IsNotePadRunning As Boolean
Private Sub Command1_Click()
Call DetectNotePad
If IsNotePadRunning Then
MsgBox "NotePad is running!", vbInformation
Else
MsgBox "NotPad is NOT running!", vbInformation
End If
End Sub

Sub DetectNotePad()
Dim hWnd As Long
hWnd = FindWindow("NOTEPAD", 0)
If hWnd = 0 Then
IsNotePadRunning = False
Exit Sub
Else
IsNotePadRunning = True
Exit Sub
End If
End Sub

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top