From d1f4f88bc2ce233ed7bc33d5f0cf40784fb5de2a Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Thu, 20 Apr 2023 11:37:25 +0800 Subject: [PATCH] Add function to get revision --- .../Exception/ExceptionFormatter.cs | 23 ++++++++++++++++--- Flow.Launcher/Helper/ErrorReporting.cs | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Exception/ExceptionFormatter.cs b/Flow.Launcher.Infrastructure/Exception/ExceptionFormatter.cs index b853f885d..63f670c66 100644 --- a/Flow.Launcher.Infrastructure/Exception/ExceptionFormatter.cs +++ b/Flow.Launcher.Infrastructure/Exception/ExceptionFormatter.cs @@ -62,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: {GetWindowsBuildVersionFromRegistry()}"); + sb.AppendLine($"* OS Version: {GetWindowsFullVersionFromRegistry()}"); sb.AppendLine($"* IntPtr Length: {IntPtr.Size}"); sb.AppendLine($"* x64: {Environment.Is64BitOperatingSystem}"); sb.AppendLine($"* Python Path: {Constant.PythonPath}"); @@ -172,13 +172,14 @@ namespace Flow.Launcher.Infrastructure.Exception } } - public static string GetWindowsBuildVersionFromRegistry() + + public static string GetWindowsFullVersionFromRegistry() { try { using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\")) { - var buildRevision = registryKey.GetValue("UBR").ToString(); + var buildRevision = GetWindowsRevisionFromRegistry(); var currentBuild = registryKey.GetValue("CurrentBuild").ToString(); return currentBuild + "." + buildRevision; } @@ -188,5 +189,21 @@ namespace Flow.Launcher.Infrastructure.Exception return Environment.OSVersion.VersionString; } } + + public static string GetWindowsRevisionFromRegistry() + { + try + { + using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\")) + { + var buildRevision = registryKey.GetValue("UBR").ToString(); + return buildRevision; + } + } + catch + { + return "0"; + } + } } } diff --git a/Flow.Launcher/Helper/ErrorReporting.cs b/Flow.Launcher/Helper/ErrorReporting.cs index db5a11f74..b5da2efad 100644 --- a/Flow.Launcher/Helper/ErrorReporting.cs +++ b/Flow.Launcher/Helper/ErrorReporting.cs @@ -33,7 +33,7 @@ namespace Flow.Launcher.Helper public static string RuntimeInfo() { var info = $"\nFlow Launcher version: {Constant.Version}" + - $"\nOS Version: {ExceptionFormatter.GetWindowsBuildVersionFromRegistry()}" + + $"\nOS Version: {ExceptionFormatter.GetWindowsFullVersionFromRegistry()}" + $"\nIntPtr Length: {IntPtr.Size}" + $"\nx64: {Environment.Is64BitOperatingSystem}"; return info;