Results 1 to 5 of 5

Thread: Closing a Window

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Post

    How can I close a window without it doing ANYTHING while it closes??? (It usually shuts another program down.)

    Thankyou!

    Evan

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    I don't get it: what do you mean by "doing ANYTHING?"

    ------------------
    Visual Basic Programmer
    ------------------
    PolComSoft
    You will hear a lot about it.


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Post

    I want to send it a command to close it without it being able to go through its Form_Unload code (Its another app).

    Is that possable?

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    You can force the App to Terminate, bypassing any Shutdown procedures it may have in place, ie.
    Code:
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
    Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
    
    Private Const PROCESS_ALL_ACCESS = &H1F0FFF
    
    Private Sub TerminateIt(ByVal lHwnd As Long)
        Dim lProcess As Long
        Dim lExitCode As Long
        
        'Get the ProcessID
        Call GetWindowThreadProcessId(lHwnd, lProcess)
        'Get the Process Handle
        lProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, lProcess)
        'Get the Exitcode
        Call GetExitCodeProcess(lProcess, lExitCode)
        'Terminate the Process
        Call TerminateProcess(lProcess, lExitCode)
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Post

    Well, The intetnet conection still disconnects when the window goes away. Could I make it so it would stay online?? thankyou aaron!

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