How to kill my own process

Posted on 2012-09-14
Last Modified: 2012-09-14
I want to be able, from code, to kill my process.  I just want to blast it out of the water -- just as if I had gone to Task Manager and used "End Process" there.  I've tried some things in my code like


I even wrote code to enumerate all windows open, look for my app's title, and then send that window a WM_CLOSE message.

But I am not killing it.

Now, I know that this must be because it launched some other process that is still active, and I shoudl really figure that out, and do something clean, but.... isn't there a way to definitively KILL myself?   Like Task Manager does.
Question by:tullhead
    LVL 86

    Accepted Solution

    The simplest ways:

    // or

    Open in new window

    LVL 86

    Expert Comment

    Or in a broader sense regarding not only your own process:;en-us;178893& ("How To Terminate an Application "Cleanly" in Win32")

    Author Closing Comment

    I like simple!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
    This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now