Results 1 to 3 of 3

Thread: Closing an application

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    13

    Thumbs up

    How do i close an application started with shell command
    N.M.

  2. #2
    Lively Member
    Join Date
    May 2000
    Location
    Antrim
    Posts
    80
    I came accross this before but unfortunately I can't remember the exact syntax.

    You need to use an API (possibly SetWindowPos, I can't remember) to set the window size to 0,0. This closes the window and therefore ends the application.

    I couldn't find a more direct way of doing it.

    Good luck.

    Best regards,

    Rob Brown.

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Declare Function FindWindowEx Lib "user32" _
    Alias "FindWindowExA" (ByVal hWnd1 As Long, _
    ByVal hWnd2 As Long, ByVal lpsz1 As String, _
    ByVal lpsz2 As String) As Long
    
    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 DestroyWindow Lib "user32" _
    (ByVal hwnd As Long) As Long
    
    Private Const WM_CLOSE = &H10
    
    Private Sub Command1_Click()
    
        Dim hApp As Long
        hApp = FindWindowEx(0&, 0&, vbNullString, "Notepad")
        If hApp <> 0 Then
            SendMessage hApp, WM_CLOSE, 0, 0
            DestroyWindow hApp
        End If
        
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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