How to kill my own process

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

theApp.pMainFrame->DestroyWindow();

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.
tullheadAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
The simplest ways:

ExitProcess(0);

// or

TerminateProcess(GetCurrentProcess(),0);

Open in new window

0
 
jkrCommented:
Or in a broader sense regarding not only your own process: http://support.microsoft.com/default.aspx?scid=KB;en-us;178893& ("How To Terminate an Application "Cleanly" in Win32")
0
 
tullheadAuthor Commented:
I like simple!

Works.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.