Nick Bolton
Nick Bolton

Reputation: 39550

On Windows, using C++, is there a way to tell an application to safely exit?

Right now, I'm using:

TerminateProcess(pi.hProcess, 0)

... but this doesn't allow the application to clean up.

Our application has a wndProc function, but when I send WM_CLOSE...

PostThreadMessage(pi.dwThreadId, WM_CLOSE, 0, 0);

The function doesn't seem to be getting the message.

pi is of type: PROCESS_INFORMATION

Upvotes: 0

Views: 153

Answers (1)

Indy9000
Indy9000

Reputation: 8851

Find your window handle (hWnd)

and call SendMessage(hWnd,WM_CLOSE,0,0);

Upvotes: 2

Related Questions