我正在开发一个用C#编写的基于.NET的桌面应用程序。如果应用程序崩溃,我想捕获有关运行该应用程序的机器的某些细节:
是否有工具或API设置可以让我方便地获得所有这些?我想做的是调用API(发生崩溃时),捕获所有细节,让用户能够将它报告给我。类似于Windows错误报告服务。
P.S:现在,我无法注册Windows Error Reporting service本身。
答案 0 :(得分:2)
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);
}