Print windows build number in log

This commit is contained in:
Vic 2023-04-19 21:07:40 +08:00
parent c61d6f791c
commit 2bba75b27a
2 changed files with 19 additions and 6 deletions

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.Win32;
namespace Flow.Launcher.Infrastructure.Exception
@ -63,7 +62,7 @@ namespace Flow.Launcher.Infrastructure.Exception
sb.AppendLine($"* Command Line: {Environment.CommandLine}");
sb.AppendLine($"* Timestamp: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
sb.AppendLine($"* Flow Launcher version: {Constant.Version}");
sb.AppendLine($"* OS Version: {Environment.OSVersion.VersionString}");
sb.AppendLine($"* OS Version: {GetWindowsBuildVersionFromRegistry()}");
sb.AppendLine($"* IntPtr Length: {IntPtr.Size}");
sb.AppendLine($"* x64: {Environment.Is64BitOperatingSystem}");
sb.AppendLine($"* Python Path: {Constant.PythonPath}");
@ -173,5 +172,21 @@ namespace Flow.Launcher.Infrastructure.Exception
}
}
public static string GetWindowsBuildVersionFromRegistry()
{
try
{
using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\"))
{
var buildRevision = registryKey.GetValue("UBR").ToString();
var currentBuild = registryKey.GetValue("CurrentBuild").ToString();
return currentBuild + "." + buildRevision;
}
}
catch
{
return Environment.OSVersion.VersionString;
}
}
}
}

View file

@ -3,8 +3,6 @@ using System.Windows.Threading;
using NLog;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Exception;
using NLog.Fluent;
using Log = Flow.Launcher.Infrastructure.Logger.Log;
namespace Flow.Launcher.Helper
{
@ -31,11 +29,11 @@ namespace Flow.Launcher.Helper
//prevent application exist, so the user can copy prompted error info
e.Handled = true;
}
public static string RuntimeInfo()
{
var info = $"\nFlow Launcher version: {Constant.Version}" +
$"\nOS Version: {Environment.OSVersion.VersionString}" +
$"\nOS Version: {ExceptionFormatter.GetWindowsBuildVersionFromRegistry()}" +
$"\nIntPtr Length: {IntPtr.Size}" +
$"\nx64: {Environment.Is64BitOperatingSystem}";
return info;