Skip to content

Commit 6f5fd16

Browse files
committed
Windows version -> System details
1 parent 96af8b8 commit 6f5fd16

File tree

4 files changed

+14
-32
lines changed

4 files changed

+14
-32
lines changed

Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.8")]
36-
[assembly: AssemblyFileVersion("1.0.0.8")]
35+
[assembly: AssemblyVersion("1.0.0.9")]
36+
[assembly: AssemblyFileVersion("1.0.0.9")]

XRFAgent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ protected override void OnStart(string[] args)
3636
modUpdate.CheckVersion();
3737
modDatabase.Load();
3838
modLogging.LogEvent("Database connected", EventLogEntryType.Information);
39-
modSystem.GetWindowsVersion();
4039
modNetwork.Load();
4140
modSync.Load();
41+
modSystem.GetSystemDetails();
4242

4343
LoadTime.Stop();
4444
modLogging.LogEvent("XRFAgent started in " + LoadTime.Elapsed.Milliseconds + " ms", EventLogEntryType.Information);

XRFAgent.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<UpdatePeriodically>false</UpdatePeriodically>
2626
<UpdateRequired>false</UpdateRequired>
2727
<MapFileExtensions>true</MapFileExtensions>
28-
<ApplicationRevision>8</ApplicationRevision>
28+
<ApplicationRevision>9</ApplicationRevision>
2929
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
3030
<UseApplicationTrust>false</UseApplicationTrust>
3131
<BootstrapperEnabled>true</BootstrapperEnabled>

modSystem.cs

+10-28
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ public static string GetSystemDetails()
100100
modDatabase.AddOrUpdateConfig(ConfigObj);
101101
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";
102102

103+
RegistryKey currentVersion = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MICROSOFT\Windows NT\CurrentVersion");
104+
105+
ConfigObj = new modDatabase.Config { Key = "System_LastKnownWindowsVersion", Value = currentVersion.GetValue("CurrentMajorVersionNumber").ToString() + "." + currentVersion.GetValue("CurrentMinorVersionNumber").ToString() + "." + currentVersion.GetValue("CurrentBuild").ToString() + "." + currentVersion.GetValue("UBR").ToString() };
106+
modDatabase.AddOrUpdateConfig(ConfigObj);
107+
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";
108+
109+
ConfigObj = new modDatabase.Config { Key = "System_OSProductName", Value = currentVersion.GetValue("ProductName").ToString() };
110+
modDatabase.AddOrUpdateConfig(ConfigObj);
111+
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";
112+
103113
RegistryKey systemHardware = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\BIOS");
104114

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

167-
/// <summary>
168-
/// Gets a full Windows build number from the registry
169-
/// </summary>
170-
/// <returns>(string) Build number</returns>
171-
public static string GetWindowsVersion()
172-
{
173-
try
174-
{
175-
RegistryKey currentVersion = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MICROSOFT\Windows NT\CurrentVersion");
176-
string currentWindowsVersion = currentVersion.GetValue("CurrentMajorVersionNumber").ToString() + "." + currentVersion.GetValue("CurrentMinorVersionNumber").ToString() + "." + currentVersion.GetValue("CurrentBuild").ToString() + "." + currentVersion.GetValue("UBR").ToString();
177-
string productName = currentVersion.GetValue("ProductName").ToString();
178-
179-
string oldWindowsVersion = modDatabase.GetConfig("System_LastKnownWindowsVersion");
180-
if (oldWindowsVersion != currentWindowsVersion)
181-
{
182-
modDatabase.AddOrUpdateConfig(new modDatabase.Config { Key = "System_LastKnownWindowsVersion", Value = currentWindowsVersion });
183-
modDatabase.AddOrUpdateConfig(new modDatabase.Config { Key = "System_OSProductName", Value = productName });
184-
}
185-
186-
return currentWindowsVersion;
187-
}
188-
catch(Exception err)
189-
{
190-
modLogging.LogEvent("Unable to get registry information: " + err.Message + "\n\n" + err.StackTrace, EventLogEntryType.Error, 6032);
191-
return "Registry error";
192-
}
193-
}
194-
195177
/// <summary>
196178
/// Reboots the host computer
197179
/// </summary>

0 commit comments

Comments
 (0)