Results 1 to 2 of 2

Thread: How to close another app with a twist

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    New Zealand
    Posts
    1

    Cool

    I am trying to close another application & can make it work with the FindWindow & PostMessage API's, however the other application needs to know the unload mode, and this can not be the same as clicking the X control button.

    My code says

    ProcessID = FindWindow(vbNullString, AppName)
    RetVal=PostMessage(ProcessID, WM_CLOSE,0,0)

    This works, however in my other program I have

    Private Sub Form_QueryUnload(Cancel as Integer, UnloadMode as Integer)

    If UnloadMode=vbFormControlMenu Then MsgBox "Are You Sure"

    End Sub

    I am trying to get the program to close without the prompt if I close it automatically, & to have the prompt if the user closes the program.

    The problem I am trying to solve revolves around the fact that the UnloadMode value is always the same as the vbFormControlMenu constant. I have tried passing other values in the 3rd & 4th parameters of the PostMessage, also tried using a SendMessage instead of PostMessage. I have also tried the TerminateProcess API but can not seem to find the correct process id to pass to it to even get it to close the program.

    Can anybody help?

    Thanks

    Steve

  2. #2
    New Member
    Join Date
    Jun 2000
    Posts
    1

    Lightbulb API_acting_on_an_other_windows_window

    This site may have the answer you need.
    check out the example on:
    http://www.vbapi.com/ref/f/findwindowex.html

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