捕获 API/工具的平台详细信息 -- Windows 错误报告等效项

Platform details capturing API/tool -- Windows Error Reporting equivalent

提问人:Rohit 提问时间:5/19/2009 更新时间:10/30/2022 访问量:338

问:

我正在开发一个用 C# 编写的基于 .NET 的桌面应用程序。如果应用程序崩溃,我想捕获有关运行应用程序的计算机的某些详细信息:

  1. 操作系统详细信息:版本、服务包等。
  2. .NET 详细信息:Framework 版本
  3. 安装的程序
  4. 崩溃时正在运行的进程。
  5. 我错过了一些东西,但应该在这里。

有没有工具或 API 集可以让我方便地获得所有这些?我想做的是调用 API(当崩溃发生时),捕获所有详细信息,并让用户能够将其报告给我。类似于 Windows 错误报告服务。

PS:现在,我无法注册Windows错误报告服务本身。

C# .NET Windows 错误报告

评论


答:

2赞 Nate 5/19/2009 #1
  1. System.OperatingSystem osInfo=System.Environment.OSVersion;

  2. 链接

  3.      string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
    
        using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registryKey)) 
        { 
            var query = from a in 
                            key.GetSubKeyNames() 
                        let r = key.OpenSubKey(a) 
                        select new 
                        { 
                            Application = r.GetValue("DisplayName") 
                        };
            
            foreach (var item in query) 
            { 
                if (item.Application != null)
                    Console.WriteLine(item.Application); 
            }
        }

(通过 http://www.onedotnetway.com/get-a-list-of-installed-applications-using-linq-and-c/)

4)

Process[] processlist = Process.GetProcesses();

foreach(Process theprocess in processlist)
{
    Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id);
}