From b74ea0071de712b22aab82328455bc49793ff784 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Thu, 20 Apr 2023 20:25:39 +0800 Subject: [PATCH] Use OSVersion.Version.Build to reduce registry access --- .../Exception/ExceptionFormatter.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Exception/ExceptionFormatter.cs b/Flow.Launcher.Infrastructure/Exception/ExceptionFormatter.cs index 63f670c66..025109e58 100644 --- a/Flow.Launcher.Infrastructure/Exception/ExceptionFormatter.cs +++ b/Flow.Launcher.Infrastructure/Exception/ExceptionFormatter.cs @@ -177,12 +177,9 @@ namespace Flow.Launcher.Infrastructure.Exception { try { - using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\")) - { - var buildRevision = GetWindowsRevisionFromRegistry(); - var currentBuild = registryKey.GetValue("CurrentBuild").ToString(); - return currentBuild + "." + buildRevision; - } + var buildRevision = GetWindowsRevisionFromRegistry(); + var currentBuild = Environment.OSVersion.Version.Build; + return currentBuild.ToString() + "." + buildRevision; } catch {