Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "windows.h"
  3. #include <vector>
  4.  
  5. LONG WINAPI CrashHandler(EXCEPTION_POINTERS *)
  6. {
  7.     MessageBox(NULL, L"Error", L"Error", MB_OK);
  8.     return EXCEPTION_EXECUTE_HANDLER;
  9. }
  10.  
  11. int _tmain(int argc, _TCHAR* argv[])
  12. {
  13.     SetUnhandledExceptionFilter(CrashHandler);
  14.  
  15.     // Crash without exception handler
  16.     std::vector<int> foo(5, 0);
  17.     for (auto& f : foo)
  18.         foo.erase(foo.begin() + 1);
  19.  
  20.     // Crash with exception handler
  21.     //volatile float* ptr = nullptr;
  22.     //float value = *ptr;
  23.  
  24.     MessageBox(NULL, L"Done", L"Done", MB_OK);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement