Something like Windows bar
Hello guys.
I have a program that run a pack of applications ussing:
Code:
x = ShellExecute(Me.hwnd, vbNullString, App.Path & "\Uplink\Uplink.exe", vbNullString, "c:\", 1)
What I want to know is to make my program know if an app is running or not, so if it is, for example, a text saying "Running" and if not, a text saying "Not running". Also a way to end an app from my program.
Thanks
Re: Something like Windows bar
At http://www.stefanthoolen.nl/basic/vb...on=FindProcess you find a module which makes it possible to search through te process list by executable name, so then you get:
Code:
Dim pe() As ProcessEntry
If FindProcess("uplink.exe", pe) Then
Label1.Caption = "Running with title: " & pe(0).Windows(0).Caption
Else
Label1.Caption = "Not running"
End If
For killing an app, I have to look it up, but I hope this helps a little so far.
Re: Something like Windows bar
For killing an app you could use this:
Code:
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Function KillProcess(processId As Long) As Boolean
Dim handle As Long, l As Long
handle = OpenProcess(&H1, False, processId)
If handle = 0 Then Exit Function
l = TerminateProcess(handle, 0)
CloseHandle handle
If l = 0 Then Exit Function
KillProcess = True
End Function
Sub Command1_Click()
Dim pe() As ProcessEntry
If FindProcess("uplink.exe", pe) Then
If Not KillProcess(pe(0).processId)) Then MsgBox "Killing failed"
End If
End Sub
Re: Something like Windows bar
Really thanks, I'll test it right away.