Skip to content

Commit

Permalink
Windows version -> System details
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdtrekkie committed Jul 9, 2024
1 parent 96af8b8 commit 6f5fd16
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.8")]
[assembly: AssemblyFileVersion("1.0.0.8")]
[assembly: AssemblyVersion("1.0.0.9")]
[assembly: AssemblyFileVersion("1.0.0.9")]
2 changes: 1 addition & 1 deletion XRFAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ protected override void OnStart(string[] args)
modUpdate.CheckVersion();
modDatabase.Load();
modLogging.LogEvent("Database connected", EventLogEntryType.Information);
modSystem.GetWindowsVersion();
modNetwork.Load();
modSync.Load();
modSystem.GetSystemDetails();

LoadTime.Stop();
modLogging.LogEvent("XRFAgent started in " + LoadTime.Elapsed.Milliseconds + " ms", EventLogEntryType.Information);
Expand Down
2 changes: 1 addition & 1 deletion XRFAgent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>8</ApplicationRevision>
<ApplicationRevision>9</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
38 changes: 10 additions & 28 deletions modSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ public static string GetSystemDetails()
modDatabase.AddOrUpdateConfig(ConfigObj);
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";

RegistryKey currentVersion = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MICROSOFT\Windows NT\CurrentVersion");

ConfigObj = new modDatabase.Config { Key = "System_LastKnownWindowsVersion", Value = currentVersion.GetValue("CurrentMajorVersionNumber").ToString() + "." + currentVersion.GetValue("CurrentMinorVersionNumber").ToString() + "." + currentVersion.GetValue("CurrentBuild").ToString() + "." + currentVersion.GetValue("UBR").ToString() };
modDatabase.AddOrUpdateConfig(ConfigObj);
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";

ConfigObj = new modDatabase.Config { Key = "System_OSProductName", Value = currentVersion.GetValue("ProductName").ToString() };
modDatabase.AddOrUpdateConfig(ConfigObj);
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";

RegistryKey systemHardware = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\BIOS");

ConfigObj = new modDatabase.Config { Key = "System_BaseBoardManufacturer", Value = systemHardware.GetValue("BaseBoardManufacturer").ToString() };
Expand Down Expand Up @@ -164,34 +174,6 @@ public static string GetSystemDetails()
}
}

/// <summary>
/// Gets a full Windows build number from the registry
/// </summary>
/// <returns>(string) Build number</returns>
public static string GetWindowsVersion()
{
try
{
RegistryKey currentVersion = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MICROSOFT\Windows NT\CurrentVersion");
string currentWindowsVersion = currentVersion.GetValue("CurrentMajorVersionNumber").ToString() + "." + currentVersion.GetValue("CurrentMinorVersionNumber").ToString() + "." + currentVersion.GetValue("CurrentBuild").ToString() + "." + currentVersion.GetValue("UBR").ToString();
string productName = currentVersion.GetValue("ProductName").ToString();

string oldWindowsVersion = modDatabase.GetConfig("System_LastKnownWindowsVersion");
if (oldWindowsVersion != currentWindowsVersion)
{
modDatabase.AddOrUpdateConfig(new modDatabase.Config { Key = "System_LastKnownWindowsVersion", Value = currentWindowsVersion });
modDatabase.AddOrUpdateConfig(new modDatabase.Config { Key = "System_OSProductName", Value = productName });
}

return currentWindowsVersion;
}
catch(Exception err)
{
modLogging.LogEvent("Unable to get registry information: " + err.Message + "\n\n" + err.StackTrace, EventLogEntryType.Error, 6032);
return "Registry error";
}
}

/// <summary>
/// Reboots the host computer
/// </summary>
Expand Down

0 comments on commit 6f5fd16

Please sign in to comment.