Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyngo committed Dec 25, 2020
0 parents commit f4b5b6e
Show file tree
Hide file tree
Showing 17 changed files with 4,522 additions and 0 deletions.
517 changes: 517 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<requestedExecutionLevel level="requireAdministrator" uiAccess="true"/>
</configuration>
25 changes: 25 additions & 0 deletions Configurator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using Microsoft.Win32;

namespace OEMConfigurator {
class Configurator {
private readonly string prefix = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation";

public string GetOEMRecord(string record) {
try {
string recordData = Registry.GetValue(prefix, record, "").ToString();
return recordData;
} catch (Exception) {
return "";
}
}

public void ChangeOEMRecord(string record, string value) {
Registry.SetValue(prefix, record, value);
}

public void RemoveOEMRecord(string record) {
Registry.SetValue(prefix, record, "");
}
}
}
251 changes: 251 additions & 0 deletions MainForm.Designer.cs

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

106 changes: 106 additions & 0 deletions MainForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

namespace OEMConfigurator {
public partial class MainForm : Form {
private Configurator cnf = new Configurator();
private string imgPath = null;
private string tmpFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\KyngoOEMConfigurator";
private string oemLogoPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\System32\oem.bmp";

public MainForm() {
InitializeComponent();
this.buildContents();
}

private void buildContents() {
this.txtManufacturer.Text = cnf.GetOEMRecord("Manufacturer");
this.txtModel.Text = cnf.GetOEMRecord("Model");
this.txtSupportHours.Text = cnf.GetOEMRecord("SupportHours");
this.txtSupportPhone.Text = cnf.GetOEMRecord("SupportPhone");
this.txtSupportURL.Text = cnf.GetOEMRecord("SupportURL");
string regLogoPath = cnf.GetOEMRecord("Logo");
if (regLogoPath != "") {
try {
if (Directory.Exists(this.tmpFolder) == true) {
Directory.Delete(this.tmpFolder, true);
}
Directory.CreateDirectory(this.tmpFolder);
if (File.Exists(oemLogoPath) == true) {
File.Copy(oemLogoPath, tmpFolder + @"\oem.bmp");
}
} catch (Exception) {
MessageBox.Show("An error occurred when reading the current OEM logo!", "Load error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
if (regLogoPath != null && regLogoPath != "") {
this.loadImage(tmpFolder + @"\oem.bmp", true);
}
}
}

private void loadImage(string imgPath, bool isFromRegistry) {
if (File.Exists(imgPath) == true) {
Bitmap bmp = new Bitmap(imgPath);

imgLogo.Image = bmp;
btnClearLogo.Enabled = true;
this.imgPath = ofdImageSelector.FileName;
} else {
if (isFromRegistry == true) {
MessageBox.Show("The specified image does not exist!\n\n" + imgPath, "Image error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} else {
MessageBox.Show("The image found in the registry does not exist!", "Image error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}

private void clickBtnChangeImage(object sender, EventArgs e) {
if (ofdImageSelector.ShowDialog() == DialogResult.OK) {
this.loadImage(ofdImageSelector.FileName, false);
}
}

private void clickBtnClearImage(object sender, EventArgs e) {
imgLogo.Image = null;
imgPath = null;
btnClearLogo.Enabled = false;
}

private void clickBtnApplyChanges(object sender, EventArgs e) {
bool copyImage = false;
if (this.imgPath != null) {
try {
if (File.Exists(oemLogoPath)) {
File.Delete(oemLogoPath);
}
File.Copy(imgPath, oemLogoPath);
copyImage = true;
} catch (Exception) {
MessageBox.Show("The logo could not be copied to a secure directory!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
copyImage = false;
}
}

cnf.ChangeOEMRecord("Manufacturer", this.txtManufacturer.Text);
cnf.ChangeOEMRecord("Model", this.txtModel.Text);
cnf.ChangeOEMRecord("SupportHours", this.txtSupportHours.Text);
cnf.ChangeOEMRecord("SupportPhone", this.txtSupportPhone.Text);
cnf.ChangeOEMRecord("SupportURL", this.txtSupportURL.Text);
if (copyImage == true) {
cnf.ChangeOEMRecord("Logo", oemLogoPath);
} else {
cnf.RemoveOEMRecord("Logo");
}

MessageBox.Show("The new settings have been applied!", "OEM Records applied", MessageBoxButtons.OK, MessageBoxIcon.Information);

}

private void clickBtnAbout(object sender, EventArgs e) {
MessageBox.Show("OEMConfigurator\n\nSimple tool to edit the OEM registry entries regarding your computer's brand and OEM specs.\n\nCreated by Kyngo\n\nhttps://github.com/Kyngo/OEMConfigurator", "OEMConfigurator", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
Loading

0 comments on commit f4b5b6e

Please sign in to comment.