3

This might be silly. When my process crashes, a WerFault.exe has been launched and I can regain control only after I close this window or kill its task.

I'm looking for a simple way of not letting crashed program show this window or any idea for me to catch this crash.

SEH is not useful, by the way. I'm not sure why. The crash also remains when I use SEH.

Thanks!

Now I'm just figuring out how to avoid this WerFault.exe windows and sometimes csrss.exe window and regain control.

Jim Yang
  • 479
  • 2
  • 12

2 Answers2

2

Use the Application Recovery and Restart API to have Windows Error Reporting (WER) restart and recover your app when it crashes. Use RegisterApplicationRestart() to register your intent to be restarted. Use RegisterApplicationRecoveryCallback() to register your intent to save and recover state data.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Good find (+1), but not sure that this will work much better for what the OP wants, since it will pop up a "Do you want to restart?" dialog when the application crashes, which is just as obnoxious as "Do you want to send an error report?". Plus, it requires the application running for at least 60 seconds, which may be a lot for a test program. – Damon Nov 05 '14 at 11:44
  • It seems not what I want. I still need to manully close the "OOPS I crashed:(" window and regain control. – Jim Yang Nov 06 '14 at 09:19
0

I have not tried this but this api : WerAddExcludedApplication should disable error raporting: http://msdn.microsoft.com/en-us/library/bb513617%28v=VS.85%29.aspx

As for restarting your app, you could create another background process that will start your main process and monitor how it behaves. If it crashes then restart it.

[edit]

unfortunately this api might not work, as suggested in comments to it - to remove this dialog your will have to FindWindow() and SendMessage(... WM_CLOSE...).

marcinj
  • 48,511
  • 9
  • 79
  • 100
  • Are you suggestting that I should create another thread that runs **FindWindow(..."WerFault.exe"...)** over and over again?.. – Jim Yang Nov 04 '14 at 03:59
  • Okay I've tried **WerAddExcludedApplication** and instead of a 'large' window, it creates a tiny window :). It's cute but not what I want. – Jim Yang Nov 04 '14 at 04:03
  • You could probably do better than FindWindow; Raymond Chen has written a number of articles about UI Automation recently, e.g., http://blogs.msdn.com/b/oldnewthing/archive/2014/02/17/10500645.aspx – Harry Johnston Nov 04 '14 at 05:47