I had a similar requirement on a previous project. I wanted to trap the crash dump file that WER produces. That is, I did not want it to be sent to the WER reporting server. That required me to set the LocalDumps WER registry key and some values. I wrote a small utility program that uses the following code snippet. Note, I had to run this code as admin.
CRegKey rk;
TCHAR pszValue[MAX_PATH+1] = {0};
DWORD dwValue = 0;
DWORD dwSize = MAX_PATH;
// check for existence of "LocalDumps" key.
LONG ret = rk.Open (HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\Windows Error Reporting"),
KEY_WRITE | KEY_WOW64_64KEY);
if (ret == ERROR_SUCCESS)
{
ret = rk.Create (rk.m_hKey, _T("LocalDumps\\<your application>.exe"));
if (ret == ERROR_SUCCESS)
{
CString szText;
DWORD dwValue = 0;
m_NumDumpsED.GetWindowText (szText);
dwValue = atol (szText);
rk.SetDWORDValue (_T("DumpCount"), dwValue);
m_DumpFolderED.GetWindowText (szText);
rk.SetStringValue (_T("DumpFolder"), szText);
dwValue = (m_MiniFullRB == 0) ? 1 : 2;
rk.SetDWORDValue (_T("DumpType"), dwValue);
}
else
AfxMessageBox (_T("Error creating 'LocalDumps\\<your application>.exe' key"), MB_OK);
}
In order to trap the dump file, you must create a child sub-key for LocalDumps that is the name of your application. That part may not be obvious in the WER documentation. As long as that key exists, WER will trap the dump. You then set the DumpCount, DumpFolder, and DumpType values to meet your needs. For more info on these values, you can consult the WER registry settings help.