I started learned windbg and I found this good post How to use WinDbg to analyze the crash dump for VC++ application?
Now I want to follow the instructions and do it
To create a crash dump, I would not write an unhandled exception handler as proposed by @Abyx for the following reasons:
a) in case of some buffer overflow or stack overflow, the code which handles the unhandled exception may be corrupt. In case of an OutOfMemoryException, how can you load another library like DbgHelp.dll?
b) the code which you have written may be buggy. Does that code check the free disk space before it writes the dump? How do you test the code to write a crash dump? Do you have a unit test for that? How does your unit test check if the dump is correct?
c) why write code at all if Windows can do it for you?
MSDN has an article on Collecting user mode dumps. Basically, there are some Registry settings which you can make. The advantage is: Windows will create the crash dump by the operating system, not by some corrupted code inside your own application.