|
-
Jul 11th, 2009, 09:42 PM
#1
Thread Starter
Junior Member
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
-
Jul 12th, 2009, 03:53 AM
#2
Lively Member
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.
If a thread is solved, please click on Thread Tools / Mark Thread Resolved .
If someone helped you very good, consider rating his post by clicking the icon under his name.
-
Jul 12th, 2009, 04:09 AM
#3
Lively Member
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
Last edited by Garrcomm; Jul 12th, 2009 at 04:19 AM.
If a thread is solved, please click on Thread Tools / Mark Thread Resolved .
If someone helped you very good, consider rating his post by clicking the icon under his name.
-
Jul 16th, 2009, 04:06 PM
#4
Thread Starter
Junior Member
Re: Something like Windows bar
Really thanks, I'll test it right away.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|