Originally Posted by
adeyblue
I'm pretty sure there's a difference between PostMessage(WM_QUIT) and PostQuitMessage(), in that one is likely to be ignored and one will end the message loop.
Since you can't PostQuitMessage to a foreign thread, just post WM_CLOSE instead. You can't set the exit code of the thread with this, but you couldn't guarantee the app would respect the exit code you set anyway.
Also CreateToolhelp32Snapshot returns INVALID_HANDLE_VALUE when it fails, that value is not 0.
STATUS_ACCESS_VIOLATION is the define.