XP generates DMP files when the application crashes-custom output

Source: Internet
Author: User

Previous ArticleArticleXP ApplicationProgramThe DMP file generated when the system crashes explains how to use the built-in drwtsn32 tool or other tools to generate the DMP file.

This article mainly describes how to use Win32 FunctionsMinidumpwritedump ()Custom DMP file output. For example, a DMP file is generated in the current directory of the application.

There are many articles on csdn about this function. The previous article is easy to understand.

Create a dump file

Http://blog.csdn.net/wxq1987525/article/details/6620927

CodeExample:

# Include "stdafx. H "# include <windows. h> # include <dbghelp. h> # pragma comment (Lib, "dbghelp. lib ") void createminidump (lpexception_pointers lpexceptioninfo) {// open a file handle hfile = createfile (_ T (" minidump. DMP "), generic_read | generic_write, 0, null, create_always, file_attribute_normal, null); If (hfile! = NULL & hfile! = Invalid_handle_value) {// create the minidump minidump_exception_information mdei; mdei. threadid = getcurrentthreadid (); mdei. predictionpointers = lpexceptioninfo; mdei. clientpointers = false; minidump_type MDT = minidumpnormal; bool retv = minidumpwritedump (getcurrentprocess (), getcurrentprocessid (), hfile, MDT, (lpexceptioninfo! = 0 )? & Mdei: 0, 0, 0); If (! Retv) {_ tprintf (_ T ("minidumpwritedump failed. error: % u \ n "), getlasterror ();} else {_ tprintf (_ T (" minidump created. \ n ");} // close the file closehandle (hfile);} else {_ tprintf (_ T (" createfile failed. error: % u \ n "), getlasterror () ;}} int _ tmain (INT argc, _ tchar * argv []) {_ Try {int * P = NULL; * P = 20;} _ expect T (createminidump (getexceptioninformation (), exception_execute_handler) {} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.