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 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; } } } }