CrashRpt使用案例详解

  // Install crash reporting

  CR_INSTALL_INFO info;

  memset(&info, 0, sizeof(CR_INSTALL_INFO));

  info.cb = sizeof(CR_INSTALL_INFO); // Sizeof the structure

  info.pszAppName = _T("APPName"); // App name

  info.pszAppVersion = _T("1.0.0"); // Appversion

  info.pszErrorReportSaveDir = _T("Crash Report");

  info.pszEmailSubject = _T("Crash Report"); // Email subject

  info.pszUrl = url;

  info.uPriorities[CR_HTTP] = 3;

  info.uPriorities[CR_SMTP] = 2;

  info.uPriorities[CR_SMAPI] = 1;

  info.dwFlags |=CR_INST_ALL_POSSIBLE_HANDLERS;

  info.dwFlags |= CR_INST_APP_RESTART;

  info.pszRestartCmdLine = _T("/restart");

  intnInstResult = crInstall(&info);

  // Check result

  if(nInstResult!=0)

  {

  TCHAR buff[512];

  crGetLastErrorMsg(buff, 512); // Get last error

  _tprintf(_T("%s

  "),buff); // and output it to the screen

  return1;

  }

  // Crash

  int a= 0;

  int b= 1 / a;

  // Uninstall

  #if defined (USE_CRASHRPT)

  crUninstall();

  #endif

  return 0;