-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f4b5b6e
Showing
17 changed files
with
4,522 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, ""); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.