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($"* Command Line: {Environment.CommandLine}");
sb.AppendLine($"* Timestamp: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); sb.AppendLine($"* Timestamp: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
sb.AppendLine($"* Flow Launcher version: {Constant.Version}"); 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($"* IntPtr Length: {IntPtr.Size}");
sb.AppendLine($"* x64: {Environment.Is64BitOperatingSystem}"); sb.AppendLine($"* x64: {Environment.Is64BitOperatingSystem}");
sb.AppendLine($"* Python Path: {Constant.PythonPath}"); sb.AppendLine($"* Python Path: {Constant.PythonPath}");
@ -172,13 +172,14 @@ namespace Flow.Launcher.Infrastructure.Exception
} }
} }
public static string GetWindowsBuildVersionFromRegistry()
public static string GetWindowsFullVersionFromRegistry()
{ {
try try
{ {
using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\")) 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(); var currentBuild = registryKey.GetValue("CurrentBuild").ToString();
return currentBuild + "." + buildRevision; return currentBuild + "." + buildRevision;
} }
@ -188,5 +189,21 @@ namespace Flow.Launcher.Infrastructure.Exception
return Environment.OSVersion.VersionString; 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() public static string RuntimeInfo()
{ {
var info = $"\nFlow Launcher version: {Constant.Version}" + var info = $"\nFlow Launcher version: {Constant.Version}" +
$"\nOS Version: {ExceptionFormatter.GetWindowsBuildVersionFromRegistry()}" + $"\nOS Version: {ExceptionFormatter.GetWindowsFullVersionFromRegistry()}" +
$"\nIntPtr Length: {IntPtr.Size}" + $"\nIntPtr Length: {IntPtr.Size}" +
$"\nx64: {Environment.Is64BitOperatingSystem}"; $"\nx64: {Environment.Is64BitOperatingSystem}";
return info; return info;