Skip to content

Commit

Permalink
Show general config info (author + laptop model/manufacturer) in conf…
Browse files Browse the repository at this point in the history
…ig editor

- Re-arrange some code into their proper sections
  • Loading branch information
Sparronator9999 committed Jan 13, 2025
1 parent 7916101 commit 393319d
Show file tree
Hide file tree
Showing 14 changed files with 408 additions and 201 deletions.
39 changes: 39 additions & 0 deletions YAMDCC.Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License along with
// YAMDCC. If not, see <https://www.gnu.org/licenses/>.

using Microsoft.Win32;
using System;
using System.ComponentModel;
using System.Diagnostics;
Expand Down Expand Up @@ -432,4 +433,42 @@ public static int RunCmd(string exe, string args, bool waitExit = true)
}
return 0;
}

/// <summary>
/// Gets the computer model name from registry.
/// </summary>
/// <returns>
/// The computer model if the function succeeds,
/// otherwise <c>null</c>.
/// </returns>
public static string GetPCModel()
{
return GetBIOSRegValue("SystemProductName");
}

/// <summary>
/// Gets the computer manufacturer from registry.
/// </summary>
/// <returns>
/// The computer manufacturer if the function succeeds,
/// otherwise <c>null</c>.
/// </returns>
public static string GetPCManufacturer()
{
return GetBIOSRegValue("SystemManufacturer");
}

private static string GetBIOSRegValue(string name)
{
RegistryKey biosKey = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\BIOS");
try
{
return (string)biosKey?.GetValue(name, null);
}
finally
{
biosKey?.Close();
}
}

}
2 changes: 1 addition & 1 deletion YAMDCC.Common/YAMDCC.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC common code library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.7</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Config/YAMDCC.Config.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC config library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.7</VersionSuffix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
139 changes: 134 additions & 5 deletions YAMDCC.ConfigEditor/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 393319d

Please sign in to comment.