Results 1 to 2 of 2

Thread: Closing a program...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Posts
    77

    Post

    How do I close a program thats running with VB? For example, if I had notepad open, how would I close it using an API?
    thx...a lot

    -Justin =]

  2. #2
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87

    Post

    Option Explicit
    Private Const WM_CLOSE = &H10

    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Private Sub CloseMirc()
    Dim hNotepad As Long
    hNotepad = FindWindow("mIRC32", vbNullString)
    Call SendMessage(hNotepad, WM_CLOSE, 0, ByVal 0&)
    End Sub

    Private Sub Command1_Click()
    CloseMirc
    End Sub


    This example shous you how to close a running program like mirc
    you need to know the real name of the program like in this case (mIRC32)

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