将 CrashDumps 转储到应用程序运行所在的同一文件夹中 [英] Make CrashDumps dump into same folder that app runs from

查看:22
本文介绍了将 CrashDumps 转储到应用程序运行所在的同一文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个应用程序,希望对其进行某种程度的自动调试.我想使用 Windows 错误报告将故障转储输出到运行应用程序的同一文件夹中.我的想法是,然后我可以让我的应用程序在它自己的文件夹中查找任何 dmp 文件,然后在需要时上传它们以进行分析.

I've written an application that I want to have some level of automatic debugging for. I want to use windows error reporting to output the crash dump into the same folder that the app is running from. My idea here is that I can then have my application look in it's own folder for any dmp files and then upload them for analysis if needed.

我有其他所有东西的适当注册表项,但如何设置 DumpFolder 项以指向我的应用程序运行的任何位置?

I've got the appropriate registry keys for everything else but how do I set up the DumpFolder key to point back to whatever location my app is ran from?

推荐答案

我在之前的一个项目中也有类似的需求.我想捕获 WER 生成的故障转储文件.也就是说,我确实希望它被发送到 WER 报告服务器.这需要我设置 LocalDumps WER 注册表项和一些值.我编写了一个使用以下代码片段的小型实用程序.请注意,我必须以 admin 身份运行此代码.

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

为了捕获转储文件,您必须为 LocalDumps 创建一个子项,即您的应用程序的名称.这部分在 WER 文档中可能并不明显.只要该密钥存在,WER 就会捕获转储.然后设置 DumpCountDumpFolderDumpType 值以满足您的需要.有关这些值的详细信息,您可以查阅 WER 注册表设置帮助.

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.

这篇关于将 CrashDumps 转储到应用程序运行所在的同一文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆