【问题标题】:Platform details capturing API/tool -- Windows Error Reporting equivalent平台详细信息捕获 API/工具——Windows 错误报告等效项
【发布时间】:2010-10-27 02:25:44
【问题描述】:

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

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

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

P.S:目前,我无法注册 Windows Error Reporting service 本身。

【问题讨论】:

    标签: c# .net windows error-reporting


    【解决方案1】:

    1) System.OperatingSystem osInfo=System.Environment.OSVersion;

    2) http://geekswithblogs.net/lorint/archive/2006/01/30/67654.aspx

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多