private void ReadImportantRegistryEntries() { //Reads registry keys Utility.ModifyRegistry.ModifyRegistry reg = new Utility.ModifyRegistry.ModifyRegistry(); reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT"; try { string s = (string)reg.Read("GPU_MAX_HEAP_SIZE"); lblGPUHeap.Text = s == null ? lblNotFound.Text : s; } catch { lblGPUHeap.Text = lblNotFound.Text; } reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers"; int val; try { val = (int)reg.Read("TdrDelay"); lblTdrDelay.Text = val.ToString(); } catch { lblTdrDelay.Text = lblNotFound.Text; } try { val = (int)reg.Read("TdrDdiDelay"); lblTdrDdiDelay.Text = val.ToString(); } catch { lblTdrDdiDelay.Text = lblNotFound.Text; } long size = 32; for (int i = 0; i < CLCalc.CLDevices.Count; i++) { if (CLCalc.CLDevices[i].Type == ComputeDeviceTypes.Gpu || CLCalc.CLDevices[i].Type == ComputeDeviceTypes.Accelerator) { if (CLCalc.CLDevices[i].GlobalMemorySize > size) { size = CLCalc.CLDevices[i].GlobalMemorySize / (1024 * 1024); } } } lblRecomHeapSize.Text = "90";// size.ToString(); lblRecomTdrDdiDelay.Text = "256"; lblRecomTdrDelay.Text = "128"; }
private void runPortableMenu_Clicked(object sender, EventArgs e) { Utility.ModifyRegistry.ModifyRegistry mr = new Utility.ModifyRegistry.ModifyRegistry(); MenuItem portMenu = (MenuItem)sender; if (portMenu.Checked == true) { portMenu.Checked = false; mr.Write("runPortable", "false"); Console.WriteLine("Writing key 'runPortable' to registry with value 'false'"); } else { portMenu.Checked = true; mr.Write("runPortable", true); Console.WriteLine("Writing key 'runPortable' to registry with value 'true'"); } }
private void btnWriteToRegistry_Click(object sender, EventArgs e) { string msg = lblConfirmModReg.Text + "\n"; msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT - GPU_MAX_HEAP_SIZE = " + lblRecomHeapSize.Text + "\n"; msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers - TdrDelay = " + lblTdrDelay.Text + "\n"; msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers - TdrDdiDelay = " + lblTdrDdiDelay.Text + "\n"; if (MessageBox.Show(msg, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Utility.ModifyRegistry.ModifyRegistry reg = new Utility.ModifyRegistry.ModifyRegistry(); reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT"; try { reg.Write("GPU_MAX_HEAP_SIZE", lblRecomHeapSize.Text); } catch { } reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers"; int val; try { int.TryParse(lblRecomTdrDelay.Text, out val); reg.Write("TdrDelay", val); } catch { } try { int.TryParse(lblRecomTdrDdiDelay.Text, out val); reg.Write("TdrDdiDelay", val); } catch { } ReadImportantRegistryEntries(); MessageBox.Show(lblReboot.Text, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnWriteToRegistry_Click(object sender, EventArgs e) { string msg = lblConfirmModReg.Text + "\n"; msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT - GPU_MAX_HEAP_SIZE = " + lblRecomHeapSize.Text + "\n"; msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers - TdrDelay = " + lblTdrDelay.Text + "\n"; msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers - TdrDdiDelay = " + lblTdrDdiDelay.Text + "\n"; if (MessageBox.Show(msg, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Utility.ModifyRegistry.ModifyRegistry reg = new Utility.ModifyRegistry.ModifyRegistry(); reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT"; try { reg.Write("GPU_MAX_HEAP_SIZE", lblRecomHeapSize.Text); } catch { } reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers"; int val; try { int.TryParse(lblRecomTdrDelay.Text, out val); reg.Write("TdrDelay", val); } catch { } try { int.TryParse(lblRecomTdrDdiDelay.Text, out val); reg.Write("TdrDdiDelay", val); } catch { } ReadImportantRegistryEntries(); MessageBox.Show(lblReboot.Text, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void ReadImportantRegistryEntries() { //Reads registry keys Utility.ModifyRegistry.ModifyRegistry reg = new Utility.ModifyRegistry.ModifyRegistry(); reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT"; try { string s = (string)reg.Read("GPU_MAX_HEAP_SIZE"); lblGPUHeap.Text = s == null ? lblNotFound.Text : s; } catch { lblGPUHeap.Text = lblNotFound.Text; } reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers"; int val; try { val = (int)reg.Read("TdrDelay"); lblTdrDelay.Text = val.ToString(); } catch { lblTdrDelay.Text = lblNotFound.Text; } try { val = (int)reg.Read("TdrDdiDelay"); lblTdrDdiDelay.Text = val.ToString(); } catch { lblTdrDdiDelay.Text = lblNotFound.Text; } long size = 32; for (int i = 0; i < CLCalc.CLDevices.Count; i++) { if (CLCalc.CLDevices[i].Type == ComputeDeviceTypes.Gpu || CLCalc.CLDevices[i].Type == ComputeDeviceTypes.Accelerator ) { if (CLCalc.CLDevices[i].GlobalMemorySize > size) size = CLCalc.CLDevices[i].GlobalMemorySize / (1024 * 1024); } } lblRecomHeapSize.Text = "90";// size.ToString(); lblRecomTdrDdiDelay.Text = "256"; lblRecomTdrDelay.Text = "128"; }
void loadSettings() { if (File.Exists(Environment.CurrentDirectory + @"\Data\settings.ini")) { try { currentConfig = settingsFile.ReadValue("Settings", "lastConfig"); if (currentConfig == "null") { //do null stuff } showAnimationPane = bool.Parse(settingsFile.ReadValue("Settings", "showAnimation")); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { Utility.ModifyRegistry.ModifyRegistry mr = new Utility.ModifyRegistry.ModifyRegistry(); try { string runPortableStr = mr.Read("runPortable"); Console.WriteLine("RegKey 'runPortable' is equal to {0}", runPortableStr.ToString()); if (runPortableStr == null) { throw new InvalidDataException(); } else if (runPortableStr == "true") { runPortable = true; runPortableEvents(); } else if (runPortableStr == "false") { runPortable = false; writeInitialIni(); loadSettings(); } else { throw new InvalidDataException(); } } catch { DialogResult dr = MessageBox.Show("We can't seem to find a Data directory alongside the NPC Editor executable. Would you like to run this application as a \"Portable\" app?", "No Data Directory Detected", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (dr) { case (DialogResult.Yes): mr.Write("runPortable", "true"); break; case (DialogResult.No): mr.Write("runPortable", "false"); writeInitialIni(); loadSettings(); break; case (DialogResult.Cancel): Environment.Exit(0); break; } } } }