We\'ve got a legacy C Windows application which pops up a modal window via the MessageBox call when a fatal connection error occurs. Our network engineers may be running many of
Can be a tricky one this.
Usually, to quit an windows application you have to quit the "Windows message loop". The easiest way to do this is to post a quit message, e.g. PostQuitMessage(retCode), where retCode is a value that your main message loop handler can process. Typically, zero, i.e. ignore.
Typically, PostQuitMessage is posted in response to a WM_DESTROY message.
It really depends on the legacy code, you have my sympathies, I am dealing with legacy code also. My code has a separate message loop and continually displays modal dialog boxes. Call EndDialog and calling PostQuitMessage(0) terminated my application correctly.