How to stop a aplication

This is a discussion on How to stop a aplication within the C++ Programming forums, part of the General Programming Boards category; I have aplication A, it launch apliction B with ShellExecute. I want to stop aplication B from aplication A. Thanks ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    13

    Question How to stop a aplication

    I have aplication A, it launch apliction B with ShellExecute.
    I want to stop aplication B from aplication A.
    Thanks for your time

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,262
    Send application B the WM_CLOSE message. If that doesnt close the application, then you can terminate the process. You can read more about this at:
    http://support.microsoft.com/default...NoWebContent=1

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    13

    Angry I tried TerminateProcess but...

    The B process continues
    I tried: TerminateProcess("som1",NULL);
    Thanks for your time

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>I tried: TerminateProcess("som1",NULL);
    TerminateProcess does NOT take a string and a pointer. You need to get a HANDLE to the target process, and specify an unsigned integer for an exit code. I don't know how you can get a handle to the process if you're using ShellExecute(), although if you use CreateProcess() instead you can specify the process ID in a call to OpenProcess() to get the process handle.

    Once you have the handle, say theHandle, and an exit code, say exitCode with a value of 0:
    TerminateProcess(theHandle, exitCode);
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 06-15-2009, 12:24 AM
  2. fscanf %s or %d integer input space char stop question...
    By transgalactic2 in forum C Programming
    Replies: 5
    Last Post: 04-14-2009, 11:44 AM
  3. Error stop Http Listener
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 06-04-2008, 03:14 AM
  4. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 04:45 PM
  5. Telling other applications to stop
    By nickname_changed in forum Windows Programming
    Replies: 11
    Last Post: 09-25-2003, 01:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21