/// <summary> /// 获取系统信息 /// </summary> /// <returns>系统信息</returns> public static string GetSystemInformation() { StringBuilder sb = new StringBuilder(); try { sb.AppendLine("ClickOnce应用程序部署版本:" + ApplicationDeployment.CurrentDeployment.CurrentVersion); } catch (Exception ex) { Debug.WriteLine(ex.Message); sb.AppendLine(string.Format("非ClickOnce应用程序。应用程序版本:{0}", App.AppVersion)); } sb.AppendLine("DoubanFM.exe版本:" + GetAssemblyVersion(typeof(App))); sb.AppendLine("DoubanFM.Core.dll版本:" + GetAssemblyVersion(typeof(Player))); sb.AppendLine("DoubanFM.Bass.dll版本:" + GetAssemblyVersion(typeof(Bass.BassEngine))); sb.AppendLine("NotifyIconWpf.dll版本:" + GetAssemblyVersion(typeof(Hardcodet.Wpf.TaskbarNotification.TaskbarIcon))); sb.AppendLine("DwmHelper.dll版本:" + GetAssemblyVersion(typeof(Kfstorm.DwmHelper.DwmHelper))); try { var os = DoubanFM.Wmi.OperatingSystem.GetInstance(); sb.AppendLine("操作系统:" + string.Format("{0} ({1})", os.Caption, Environment.OSVersion)); } catch { try { sb.AppendLine("操作系统:" + Environment.OSVersion); } catch { } } try { sb.AppendLine("工作目录:" + Environment.CurrentDirectory); } catch { } try { sb.AppendLine("命令行:" + Environment.CommandLine); } catch { } try { sb.AppendLine("Temp文件夹:" + System.IO.Path.GetTempPath()); } catch { } try { sb.AppendLine("是否是64位操作系统:" + (Environment.Is64BitOperatingSystem ? "是" : "否")); } catch { } try { sb.AppendLine("是否是64位进程:" + (Environment.Is64BitProcess ? "是" : "否")); } catch { } try { sb.AppendLine("处理器数:" + Environment.ProcessorCount); } catch { } try { sb.AppendLine("系统目录:" + Environment.SystemDirectory); } catch { } try { sb.AppendLine("CLR版本:" + Environment.Version); } catch { } try { sb.AppendLine("工作集大小:" + Environment.WorkingSet); } catch { } try { sb.AppendLine("屏幕分辨率:" + SystemParameters.PrimaryScreenWidth + "x" + SystemParameters.PrimaryScreenHeight); } catch { } try { sb.AppendLine("工作区大小:" + SystemParameters.WorkArea.Width + "x" + SystemParameters.WorkArea.Height); } catch { } try { Processor[] processors = Processor.GetInstances(); foreach (var processor in processors) { sb.AppendLine("处理器:" + processor.Name); } } catch { } try { PhysicalMemory[] memories = PhysicalMemory.GetInstances(); ulong memorySize = 0; foreach (var memory in memories) { memorySize += memory.Capacity; } sb.AppendLine("内存:" + PhysicalMemory.FormatBytes(memorySize)); } catch { } try { DisplayConfiguration[] displayes = DisplayConfiguration.GetInstances(); foreach (var display in displayes) { sb.AppendLine("显卡:" + display.DeviceName); } } catch { } try { SoundDevice[] devices = SoundDevice.GetInstances(); foreach (var device in devices) { sb.AppendLine("声卡:" + device.Name); } } catch { } return(sb.ToString()); }