Results 1 to 4 of 4

Thread: Something like Windows bar

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2009
    Posts
    21

    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

  2. #2
    Lively Member Garrcomm's Avatar
    Join Date
    Jul 2009
    Location
    the Netherlands
    Posts
    87

    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.

  3. #3
    Lively Member Garrcomm's Avatar
    Join Date
    Jul 2009
    Location
    the Netherlands
    Posts
    87

    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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2009
    Posts
    21

    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
  •  



Click Here to Expand Forum to Full Width