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 ;}