2

I trying to find any solution from 2 days, but i didn't find anything usefull. I need to close my app from aplication code with returning value. I know, i need to use ExitInstance, it's work's fine but only when i add window and press X to close my app. I need to force my app to close from code (something like to fore ExitInstance). Any solutions?

Yardi
  • 413
  • 1
  • 5
  • 20
  • 1
    Possible duplicate of [What is the correct way to programmatically quit an MFC application?](https://stackoverflow.com/questions/7562335/what-is-the-correct-way-to-programmatically-quit-an-mfc-application) – nvoigt Jan 09 '18 at 09:16

1 Answers1

4

Use the PostQuitMessage function, passing an appropriate exit code as its only argument, i.e.

PostQuitMessage(0); //Everything went fine

or

PostQuitMessage(-1); //Troubles occurred
p-a-o-l-o
  • 9,807
  • 2
  • 22
  • 35