Results 1 to 8 of 8

Thread: closing a running exe

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    closing a running exe

    Hi,
    how wud i be able to close my running VB exe while it is running........?

    Thanks and Regards
    vivek.s

  2. #2
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: closing a running exe

    Task manager.
    Never tried it in code.
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: closing a running exe

    Quote Originally Posted by vivek.shankar
    Hi,
    how wud i be able to close my running VB exe while it is running........?

    Thanks and Regards
    vivek.s
    If you mean from inside the running program then do this

    Code:
    Public Sub UnloadAllForms()
    
    For Each frm In Forms
        Unload frm
        Set frm = Nothing
    Next
    
    Exit Sub

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: closing a running exe

    i wanted one program to close another exe.........like we go and close using taskbar.......

    thanks and regards
    vivek.s

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: closing a running exe

    Code:
    Private Declare Function CloseWindow Lib "user32" Alias "CloseWindow" (ByVal hwnd As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Dim lngRetVal as long
    lngRetVal=FindWindow(vbnullstring,"Name of my App")
    CloseWindow lngRetval

  6. #6

    Re: closing a running exe

    the process could still be open or the process even dont have a form...

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: closing a running exe

    yes exactly.......sometimes form is closed but process is still in the memory.......

    regards
    vivek.s

  8. #8

    Re: closing a running exe

    you should try TerminateProcess API i dont even know if it exists though you could try

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