Add function to get revision

This commit is contained in:
VictoriousRaptor 2023-04-20 11:37:25 +08:00
parent 2bba75b27a
commit d1f4f88bc2
2 changed files with 21 additions and 4 deletions

View file

@ -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";
}
}
}
}

View file

@ -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;