By the sytem: https://learn.microsoft.com/zh-cn/windows/win32/wer/collecting-user-mode-dumps
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /v DumpType /t REG_DWORD /d 2 /f
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /v DumpCount /t REG_DWORD /d 3 /f
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /v DumpFolder /t REG_EXPAND_SZ /d C:\app\CrashDumps /f
By programmatical:
https://stackoverflow.com/questions/1547211/how-to-create-minidump-for-my-process-when-it-crashes#1547251