//Delete the powermizer Name/Value entries in the registry (for example, to use prior a reg restore) public void deletePowermizerSettings() { if (this.nvidiaKey != null) { log("Deleting Powermizer settings from the registry..."); try { //Let's extract the name of the keys from a settings struct PwrMzrSettings auxstruct = new PwrMzrSettings(PwrMzrValue.DEFAULT); this.regmgr.deleteValue(this.nvidiaKey, auxstruct.PowerMizerEnabled.EntryName); this.regmgr.deleteValue(this.nvidiaKey, auxstruct.PowerMizerGovernor.EntryName); this.regmgr.deleteValue(this.nvidiaKey, auxstruct.PowerMizerBatteryFixedLevel.EntryName); this.regmgr.deleteValue(this.nvidiaKey, auxstruct.PowerMizerACFixedLevel.EntryName); //SLI/HYBRID SUPPORT if (Properties.Settings.Default.SLIModeEnabled == true) { this.regmgr.deleteValue(this.nvidiaSLIKey, auxstruct.PowerMizerEnabled.EntryName); this.regmgr.deleteValue(this.nvidiaSLIKey, auxstruct.PowerMizerGovernor.EntryName); this.regmgr.deleteValue(this.nvidiaSLIKey, auxstruct.PowerMizerBatteryFixedLevel.EntryName); this.regmgr.deleteValue(this.nvidiaSLIKey, auxstruct.PowerMizerACFixedLevel.EntryName); } deletePowermizerSlowDownSettings(); //Flush the key for the changes to take effect this.regmgr.PersistKeyChanges(this.nvidiaKey); logsub("Success..."); //SLI/HYBRID SUPPORT if (Properties.Settings.Default.SLIModeEnabled == true) { this.regmgr.PersistKeyChanges(this.nvidiaSLIKey); logsub("Success... (SLIKey)."); } } catch { //All errors logged throw; } } }
//Apply selected settings and reboot private void buttonReboot_Click(object sender, EventArgs e) { if (this.testConfig()) { PwrMzrSettings pm = this.collectDataFromControls(); try { if (MessageBox.Show("The changes will be applied to the registry.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.pwrmzrManager.changePowermizerSettings(pm); } else { return; } } catch { //All errors logged MessageBox.Show("Could't change powermizer settings. Check debug console for more details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } try { if (MessageBox.Show("Do you want to reboot NOW?. Click NO if you want to reboot manually.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { WindowsController.ExitWindows(RestartOptions.Reboot, false); } else { return; } } catch { log("Error while rebooting!. Try rebooting manually."); return; } } }
//Create powermizer settings button click event private void buttonInsert_Click(object sender, EventArgs e) { if (MessageBox.Show("Powermizer Settings will be created in the registry.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { log("Inserting Default Powermizer entries..."); try { PwrMzrSettings pmset = new PwrMzrSettings(PwrMzrValue.DEFAULT); this.pwrmzrManager.changePowermizerSettings(pmset); logsub("Success..."); } catch { //All errors logged MessageBox.Show("Could't create registry settings. Check debug console for more details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } //Reinitialize the dialog this.Initialize(); }
//Create a powermizerSettings structure from the controls configuration private PwrMzrSettings collectDataFromControls() { PwrMzrValue pm_enab, gov, battfix, acfix; PwrMzrValue OHSDEnabled = PwrMzrValue.PM_DISABLED, OHSDMem = PwrMzrValue.PM_DISABLED, OHSDCore = PwrMzrValue.PM_DISABLED; bool OHSDOverride=false; PwrMzrSettings pmset; log("Reading dialog..."); //Checkbox ENABLE/DISABLE Powermizer if (!this.checkBoxEnablePM.Checked) { pm_enab = PwrMzrValue.PM_DISABLED; gov = PwrMzrValue.BAT_FIXED_AC_FIXED; battfix = PwrMzrValue.PM_DISABLED; acfix = PwrMzrValue.PM_DISABLED; } else { pm_enab = PwrMzrValue.PM_ENABLED; //Governor if(this.radioButtonATBAtt.Checked){ if(this.radioButtonATAC.Checked) { //0x3333 gov = PwrMzrValue.BAT_ON_AC_ON; acfix= PwrMzrValue.MAX_PERF; battfix = PwrMzrValue.MAX_PERF; } else { //0x3322 gov = PwrMzrValue.BAT_ON_AC_FIXED; acfix = ((KeyValuePair<PwrMzrValue, string>)this.comboBoxLevelAC.SelectedItem).Key; battfix = PwrMzrValue.MAX_PERF; } } else { if (this.radioButtonATAC.Checked) { //0x2233 gov = PwrMzrValue.BAT_FIXED_AC_ON; battfix = ((KeyValuePair<PwrMzrValue, string>)this.comboBoxLevelBatt.SelectedItem).Key; acfix = PwrMzrValue.MAX_PERF; } else { //0x2222 gov = PwrMzrValue.BAT_FIXED_AC_FIXED; acfix = ((KeyValuePair<PwrMzrValue, string>)this.comboBoxLevelAC.SelectedItem).Key; battfix = ((KeyValuePair<PwrMzrValue, string>)this.comboBoxLevelBatt.SelectedItem).Key; } } } //Overheat slowdown if (this.checkBoxEnableSlowDown.Checked) { OHSDOverride = true; int key = ((KeyValuePair<int, string>)this.comboBoxSlowDown.SelectedItem).Key; switch (key) { case 1: OHSDEnabled = PwrMzrValue.PM_DISABLED; OHSDMem = PwrMzrValue.PM_DISABLED; OHSDCore = PwrMzrValue.PM_DISABLED; break; case 2: OHSDEnabled = PwrMzrValue.PM_ENABLED; OHSDMem = PwrMzrValue.PM_ENABLED; OHSDCore = PwrMzrValue.PM_DISABLED; break; case 3: OHSDEnabled = PwrMzrValue.PM_ENABLED; OHSDMem = PwrMzrValue.PM_DISABLED; OHSDCore = PwrMzrValue.PM_ENABLED; break; case 4: OHSDEnabled = PwrMzrValue.PM_ENABLED; OHSDMem = PwrMzrValue.PM_ENABLED; OHSDCore = PwrMzrValue.PM_ENABLED; break; } } else //They're already initialized. This else can be deleted { OHSDOverride = false; OHSDEnabled = PwrMzrValue.PM_DISABLED; OHSDMem = PwrMzrValue.PM_DISABLED; OHSDCore = PwrMzrValue.PM_DISABLED; } pmset = new PwrMzrSettings(pm_enab, gov, battfix, acfix, OHSDOverride, OHSDEnabled, OHSDMem, OHSDCore); if (pmset.PowerMizerEnabled.EntryValue == PwrMzrValue.PM_ENABLED) { log("Powermizer will be ENABLED"); } else { log("Powermizer will be DISABLED"); } logsub("Selected Governor: " + pmset.PowerMizerGovernor.EntryValue.ToString()); logsub("Selected Fixed Batt Level: " + pmset.PowerMizerBatteryFixedLevel.EntryValue.ToString()); logsub("Selected Fixed AC Level: " + pmset.PowerMizerACFixedLevel.EntryValue.ToString()); if (pmset.OverheatSlowdownOverride) { logsub("Overheat Slowdown settings will be OVERRIDEN"); if (pmset.OverheatSlowdownEnabled.EntryValue == PwrMzrValue.PM_ENABLED) { logsub("Overheat Slowdown is ENABLED."); } else { logsub("Overheat Slowdown is DISABLED."); } if (pmset.OverheatSlowdownMemory.EntryValue == PwrMzrValue.PM_ENABLED) { logsub("Overheat MEMORY Slowdown is ENABLED."); } else { logsub("Overheat MEMORY Slowdown is DISABLED."); } if (pmset.OverheatSlowdownCore.EntryValue == PwrMzrValue.PM_ENABLED) { logsub("Overheat CORE Slowdown is ENABLED."); } else { logsub("Overheat CORE Slowdown is DISABLED."); } } else { logsub("Will NOT override Overheat Slowdown settings"); } return pmset; }
//Create powermizer settings button click event private void buttonInsert_Click(object sender, EventArgs e) { if (MessageBox.Show("Powermizer Settings will be created in the registry.", "Confirmation", MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes) { log("Inserting Default Powermizer entries..."); try { PwrMzrSettings pmset = new PwrMzrSettings(PwrMzrValue.DEFAULT); this.pwrmzrManager.changePowermizerSettings(pmset); logsub("Success..."); } catch { //All errors logged MessageBox.Show("Could't create registry settings. Check debug console for more details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } //Reinitialize the dialog this.Initialize(); }
//Instant Apply! button private void buttonApplyNow_Click(object sender, EventArgs e) { //IF shift is hold while ckicking on the button, skip all the unnecessary checks to speed up the settings applying. INSANE INSTANT APPLY! bool skipChecks = false; if ((Control.ModifierKeys & Keys.Shift) != 0) { skipChecks = true; } if (this.testConfig()) { PwrMzrSettings pm = this.collectDataFromControls(); try { if (skipChecks == false) { if (MessageBox.Show("The changes will be applied to the registry.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.pwrmzrManager.changePowermizerSettings(pm); } else { return; } } else { //Skipping checks. Right to the nitty-gritty this.pwrmzrManager.changePowermizerSettings(pm); } } catch { //All errors logged MessageBox.Show("Could't change powermizer settings. Check debug console for more details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //Instant Apply! try { log("Trying Instant Apply! ..."); //Query the data List <string> data = this.pwrmzrManager.readInstantApplyInfo(); Guid videoGuid = new Guid(data[0]); string instancePath = data[1].ToUpper(); //SLI SUPPORT string instancePathSLI = null; if (Properties.Settings.Default.SLIModeEnabled == true) { if (data.Count == 3) { instancePathSLI = data[2].ToUpper(); } } InstantApplyDisc dlg = new InstantApplyDisc(); DialogResult result; if (skipChecks == false) { result = dlg.ShowDialog(); } else //If we are skipping checks, let's go for it without showing any dialog at all. { result = DialogResult.OK; } if (result == DialogResult.OK) { //Reboot the device logsub("Reinitializing device: " + instancePath); DeviceHelper.SetDeviceEnabled(videoGuid, instancePath, false); DeviceHelper.SetDeviceEnabled(videoGuid, instancePath, true); logsub("Success..."); //SLI SUPPORT if (Properties.Settings.Default.SLIModeEnabled == true) { if (instancePathSLI != null)//If we really have another device here, let's reboot it { //Reboot the device logsub("Reinitializing SLI device: " + instancePathSLI); DeviceHelper.SetDeviceEnabled(videoGuid, instancePathSLI, false); DeviceHelper.SetDeviceEnabled(videoGuid, instancePathSLI, true); logsub("Success... (SLIDevice)."); } } //dirty patch: After rebooting the device, due to temporary resolution change, //the width of the dialog changes, so we fix it here. if (this.expanded) { this.Width = 900; } else { this.Width = 470; } } else { return; } } catch { logsub("Error while trying Instant Apply! . Try rebooting manually."); MessageBox.Show("At the moment your system does not support the Instant Apply! feature. Check debug console for more details."); return; } } }
//Create a powermizerSettings structure from the controls configuration private PwrMzrSettings collectDataFromControls() { PwrMzrValue pm_enab, gov, battfix, acfix; PwrMzrValue OHSDEnabled = PwrMzrValue.PM_DISABLED, OHSDMem = PwrMzrValue.PM_DISABLED, OHSDCore = PwrMzrValue.PM_DISABLED; bool OHSDOverride = false; PwrMzrSettings pmset; log("Reading dialog..."); //Checkbox ENABLE/DISABLE Powermizer if (!this.checkBoxEnablePM.Checked) { pm_enab = PwrMzrValue.PM_DISABLED; gov = PwrMzrValue.BAT_FIXED_AC_FIXED; battfix = PwrMzrValue.PM_DISABLED; acfix = PwrMzrValue.PM_DISABLED; } else { pm_enab = PwrMzrValue.PM_ENABLED; //Governor if (this.radioButtonATBAtt.Checked) { if (this.radioButtonATAC.Checked) { //0x3333 gov = PwrMzrValue.BAT_ON_AC_ON; acfix = PwrMzrValue.MAX_PERF; battfix = PwrMzrValue.MAX_PERF; } else { //0x3322 gov = PwrMzrValue.BAT_ON_AC_FIXED; acfix = ((KeyValuePair <PwrMzrValue, string>) this.comboBoxLevelAC.SelectedItem).Key; battfix = PwrMzrValue.MAX_PERF; } } else { if (this.radioButtonATAC.Checked) { //0x2233 gov = PwrMzrValue.BAT_FIXED_AC_ON; battfix = ((KeyValuePair <PwrMzrValue, string>) this.comboBoxLevelBatt.SelectedItem).Key; acfix = PwrMzrValue.MAX_PERF; } else { //0x2222 gov = PwrMzrValue.BAT_FIXED_AC_FIXED; acfix = ((KeyValuePair <PwrMzrValue, string>) this.comboBoxLevelAC.SelectedItem).Key; battfix = ((KeyValuePair <PwrMzrValue, string>) this.comboBoxLevelBatt.SelectedItem).Key; } } } //Overheat slowdown if (this.checkBoxEnableSlowDown.Checked) { OHSDOverride = true; int key = ((KeyValuePair <int, string>) this.comboBoxSlowDown.SelectedItem).Key; switch (key) { case 1: OHSDEnabled = PwrMzrValue.PM_DISABLED; OHSDMem = PwrMzrValue.PM_DISABLED; OHSDCore = PwrMzrValue.PM_DISABLED; break; case 2: OHSDEnabled = PwrMzrValue.PM_ENABLED; OHSDMem = PwrMzrValue.PM_ENABLED; OHSDCore = PwrMzrValue.PM_DISABLED; break; case 3: OHSDEnabled = PwrMzrValue.PM_ENABLED; OHSDMem = PwrMzrValue.PM_DISABLED; OHSDCore = PwrMzrValue.PM_ENABLED; break; case 4: OHSDEnabled = PwrMzrValue.PM_ENABLED; OHSDMem = PwrMzrValue.PM_ENABLED; OHSDCore = PwrMzrValue.PM_ENABLED; break; } } else //They're already initialized. This else can be deleted { OHSDOverride = false; OHSDEnabled = PwrMzrValue.PM_DISABLED; OHSDMem = PwrMzrValue.PM_DISABLED; OHSDCore = PwrMzrValue.PM_DISABLED; } pmset = new PwrMzrSettings(pm_enab, gov, battfix, acfix, OHSDOverride, OHSDEnabled, OHSDMem, OHSDCore); if (pmset.PowerMizerEnabled.EntryValue == PwrMzrValue.PM_ENABLED) { log("Powermizer will be ENABLED"); } else { log("Powermizer will be DISABLED"); } logsub("Selected Governor: " + pmset.PowerMizerGovernor.EntryValue.ToString()); logsub("Selected Fixed Batt Level: " + pmset.PowerMizerBatteryFixedLevel.EntryValue.ToString()); logsub("Selected Fixed AC Level: " + pmset.PowerMizerACFixedLevel.EntryValue.ToString()); if (pmset.OverheatSlowdownOverride) { logsub("Overheat Slowdown settings will be OVERRIDEN"); if (pmset.OverheatSlowdownEnabled.EntryValue == PwrMzrValue.PM_ENABLED) { logsub("Overheat Slowdown is ENABLED."); } else { logsub("Overheat Slowdown is DISABLED."); } if (pmset.OverheatSlowdownMemory.EntryValue == PwrMzrValue.PM_ENABLED) { logsub("Overheat MEMORY Slowdown is ENABLED."); } else { logsub("Overheat MEMORY Slowdown is DISABLED."); } if (pmset.OverheatSlowdownCore.EntryValue == PwrMzrValue.PM_ENABLED) { logsub("Overheat CORE Slowdown is ENABLED."); } else { logsub("Overheat CORE Slowdown is DISABLED."); } } else { logsub("Will NOT override Overheat Slowdown settings"); } return(pmset); }
//Initialize the frame2 controls private void InitializeSettingsControls() { try { PwrMzrSettings pmset = this.pwrmzrManager.readPowermizerSettings(); log("Populating Dialog Controls..."); //Powermizer_Enabled checkbox if (pmset.PowerMizerEnabled.EntryValue == PwrMzrValue.PM_DISABLED) { this.checkBoxEnablePM.Checked = false; } else { this.checkBoxEnablePM.Checked = true; } this.checkBoxEnablePM_CheckedChanged(null, null); //Powermizer radiobuttons switch (pmset.PowerMizerGovernor.EntryValue) { case PwrMzrValue.BAT_ON_AC_ON: this.radioButtonATBAtt_Click(null, null); this.radioButtonATAC_Click(null, null); break; case PwrMzrValue.BAT_ON_AC_FIXED: this.radioButtonATBAtt_Click(null, null); this.radioButtonFixedAC_Click(null, null); break; case PwrMzrValue.BAT_FIXED_AC_ON: this.radioButtonFixedBatt_Click(null, null); this.radioButtonATAC_Click(null, null); break; case PwrMzrValue.BAT_FIXED_AC_FIXED: this.radioButtonFixedBatt_Click(null, null); this.radioButtonFixedAC_Click(null, null); break; } //BAttery fixed combo foreach (KeyValuePair <PwrMzrValue, string> pair in this.comboBoxLevelBatt.Items) { if (pair.Key == pmset.PowerMizerBatteryFixedLevel.EntryValue) { this.comboBoxLevelBatt.SelectedItem = pair; break; } } //AC fixed combo foreach (KeyValuePair <PwrMzrValue, string> pair in this.comboBoxLevelAC.Items) { if (pair.Key == pmset.PowerMizerACFixedLevel.EntryValue) { this.comboBoxLevelAC.SelectedItem = pair; break; } } //Overheat Slowdown if (pmset.OverheatSlowdownOverride) { int selected = 0; this.checkBoxEnableSlowDown.Checked = true; if (pmset.OverheatSlowdownEnabled.EntryValue == PwrMzrValue.PM_ENABLED) { if (pmset.OverheatSlowdownMemory.EntryValue == PwrMzrValue.PM_ENABLED) { if (pmset.OverheatSlowdownCore.EntryValue == PwrMzrValue.PM_ENABLED) { //MEM & Core Slowdown selected = 4; } else { //MEM Slowdown Only selected = 2; } } else { if (pmset.OverheatSlowdownCore.EntryValue == PwrMzrValue.PM_ENABLED) { //COre Slowdown Only selected = 3; } else { //Slowdown disabled on both MEM & Core. This state is the same as OverheatSlowdownEnabled==PM_DISABLED selected = 1; } } } else //Slowdown Disabled { selected = 1; } foreach (KeyValuePair <int, string> k in this.comboBoxSlowDown.Items) { if (k.Key == selected) { this.comboBoxSlowDown.SelectedItem = k; } } } else { this.checkBoxEnableSlowDown.Checked = false; } this.checkBoxEnableSlowDown_CheckedChanged(null, null); logsub("Success..."); } catch { //Errors already logged MessageBox.Show("Couldn't read PowerMizer settings. Check debug console for more details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } }
//Modify the Powermizer Settings public void changePowermizerSettings(PwrMzrSettings settings) { if (this.nvidiaKey != null) { log("Writing Powermizer settings into the registry..."); try { this.regmgr.setValue(this.nvidiaKey, settings.PowerMizerEnabled.EntryName, settings.PowerMizerEnabled.EntryValue, settings.PowerMizerEnabled.EntryType); this.regmgr.setValue(this.nvidiaKey, settings.PowerMizerGovernor.EntryName, settings.PowerMizerGovernor.EntryValue, settings.PowerMizerGovernor.EntryType); this.regmgr.setValue(this.nvidiaKey, settings.PowerMizerBatteryFixedLevel.EntryName, settings.PowerMizerBatteryFixedLevel.EntryValue, settings.PowerMizerBatteryFixedLevel.EntryType); this.regmgr.setValue(this.nvidiaKey, settings.PowerMizerACFixedLevel.EntryName, settings.PowerMizerACFixedLevel.EntryValue, settings.PowerMizerACFixedLevel.EntryType); //SLI/HYBRID SUPPORT if (Properties.Settings.Default.SLIModeEnabled == true) { this.regmgr.setValue(this.nvidiaSLIKey, settings.PowerMizerEnabled.EntryName, settings.PowerMizerEnabled.EntryValue, settings.PowerMizerEnabled.EntryType); this.regmgr.setValue(this.nvidiaSLIKey, settings.PowerMizerGovernor.EntryName, settings.PowerMizerGovernor.EntryValue, settings.PowerMizerGovernor.EntryType); this.regmgr.setValue(this.nvidiaSLIKey, settings.PowerMizerBatteryFixedLevel.EntryName, settings.PowerMizerBatteryFixedLevel.EntryValue, settings.PowerMizerBatteryFixedLevel.EntryType); this.regmgr.setValue(this.nvidiaSLIKey, settings.PowerMizerACFixedLevel.EntryName, settings.PowerMizerACFixedLevel.EntryValue, settings.PowerMizerACFixedLevel.EntryType); } //Overheat SlowDown if (settings.OverheatSlowdownOverride) { logsub("Overriding Overheat Slowdown settings..."); this.regmgr.setValue(this.nvidiaKey, settings.OverheatSlowdownEnabled.EntryName, settings.OverheatSlowdownEnabled.EntryValue, settings.OverheatSlowdownEnabled.EntryType); this.regmgr.setValue(this.nvidiaKey, settings.OverheatSlowdownMemory.EntryName, settings.OverheatSlowdownMemory.EntryValue, settings.OverheatSlowdownMemory.EntryType); this.regmgr.setValue(this.nvidiaKey, settings.OverheatSlowdownCore.EntryName, settings.OverheatSlowdownCore.EntryValue, settings.OverheatSlowdownCore.EntryType); //SLI SUPPORT if (Properties.Settings.Default.SLIModeEnabled == true) { this.regmgr.setValue(this.nvidiaSLIKey, settings.OverheatSlowdownEnabled.EntryName, settings.OverheatSlowdownEnabled.EntryValue, settings.OverheatSlowdownEnabled.EntryType); this.regmgr.setValue(this.nvidiaSLIKey, settings.OverheatSlowdownMemory.EntryName, settings.OverheatSlowdownMemory.EntryValue, settings.OverheatSlowdownMemory.EntryType); this.regmgr.setValue(this.nvidiaSLIKey, settings.OverheatSlowdownCore.EntryName, settings.OverheatSlowdownCore.EntryValue, settings.OverheatSlowdownCore.EntryType); } } else //If we dont want them overriden { if (this.regmgr.getDataValue(this.nvidiaKey, settings.OverheatSlowdownEnabled.EntryName) != null)//If they were overriden before { this.deletePowermizerSlowDownSettings(); } } //Flush the key for the changes to take effect this.regmgr.PersistKeyChanges(this.nvidiaKey); logsub("Success..."); //SLI SUPPORT if (Properties.Settings.Default.SLIModeEnabled == true) { this.regmgr.PersistKeyChanges(this.nvidiaSLIKey); logsub("Success... (SLIKey)."); } } catch { //All errors logged throw; } } }
//Read the prowermizer Settings public PwrMzrSettings readPowermizerSettings() { //Read the settings from the registry log("Extracting PowerMizer settings..."); object enab, gov, batfix, acfix; object sdenab, sdmem, sdcore; bool sdoverr=false; try { //Let's extract the name of the keys from a settings struct PwrMzrSettings auxstruct = new PwrMzrSettings(PwrMzrValue.DEFAULT); enab = regmgr.getDataValue(this.nvidiaKey, auxstruct.PowerMizerEnabled.EntryName); gov = regmgr.getDataValue(this.nvidiaKey, auxstruct.PowerMizerGovernor.EntryName); batfix = regmgr.getDataValue(this.nvidiaKey, auxstruct.PowerMizerBatteryFixedLevel.EntryName); acfix = regmgr.getDataValue(this.nvidiaKey, auxstruct.PowerMizerACFixedLevel.EntryName); //This settings may not be there! sdenab = regmgr.getDataValue(this.nvidiaKey, auxstruct.OverheatSlowdownEnabled.EntryName); sdmem = regmgr.getDataValue(this.nvidiaKey, auxstruct.OverheatSlowdownMemory.EntryName); sdcore = regmgr.getDataValue(this.nvidiaKey, auxstruct.OverheatSlowdownCore.EntryName); } catch { logsub("There were some major problems while reading the PowerMizer Settings."); throw; } //Patch in 0.95. Detect inconsistet registry keys caused by playing with different driver versions. //In some rare cases, the PerfLevelSrc entry is there, but the others are not, leading to strange situations. This provides a way out. if ((enab == null) || (gov == null) || (batfix == null) || (acfix == null)) { logsub("Your Registry settings seem to be inconsistent. You have **SOME** of the required entries for PowerMizer Management, but strangely enough, not **ALL** of them.This can be caused by installing/uninstalling several different drivers versions."); logsub("Please click the [Delete Powermizer Settings] button, and then on [Create Powermizer Settings] button again. This should solve the trouble. In case it does not, please send debug info to devs through the [Problems?] button."); throw new Exception(); } logsub("Success..."); //Create the settings structure (convert from object to the enumtype) PwrMzrValue governor = (PwrMzrValue)Enum.ToObject(typeof(PwrMzrValue), gov); PwrMzrValue levelbatt = (PwrMzrValue)Enum.ToObject(typeof(PwrMzrValue), batfix); PwrMzrValue levelac = (PwrMzrValue)Enum.ToObject(typeof(PwrMzrValue), acfix); PwrMzrValue pm_enab; if (Convert.ToBoolean(enab)) { pm_enab = PwrMzrValue.PM_ENABLED; logsub("Powermizer is ENABLED."); } else { pm_enab = PwrMzrValue.PM_DISABLED; logsub("Powermizer is DISABLED."); } logsub("Actual Governor: " + governor.ToString()); logsub("Actual Fixed Batt Level: " + levelbatt.ToString()); logsub("Actual Fixed AC Level: " + levelac.ToString()); //This settings may not be there, so we may have a bunch if nulls. Careful! PwrMzrValue OHSDEnabled = PwrMzrValue.PM_DISABLED, OHSDMemory = PwrMzrValue.PM_DISABLED, OHSDCore = PwrMzrValue.PM_DISABLED; if (sdenab != null) { sdoverr = true; logsub("Overheat Slowdown settings are OVERRIDEN..."); if (Convert.ToBoolean(sdenab)) { OHSDEnabled = PwrMzrValue.PM_ENABLED; logsub("Overheat Slowdown is ENABLED."); } else { OHSDEnabled = PwrMzrValue.PM_DISABLED; logsub("Overheat Slowdown is DISABLED."); } if (Convert.ToBoolean(sdmem)) { OHSDMemory = PwrMzrValue.PM_ENABLED; logsub("Overheat MEMORY Slowdown is ENABLED."); } else { OHSDMemory = PwrMzrValue.PM_DISABLED; logsub("Overheat MEMORY Slowdown is DISABLED."); } if (Convert.ToBoolean(sdcore)) { OHSDCore = PwrMzrValue.PM_ENABLED; logsub("Overheat CORE Slowdown is ENABLED."); } else { OHSDCore = PwrMzrValue.PM_DISABLED; logsub("Overheat CORE Slowdown is DISABLED."); } } else { sdoverr = false; logsub("No Overheat Slowdown settings found..."); } //Create the settings to return them PwrMzrSettings pmset; if (sdoverr) //IF we have detected overriden settings we need to take them into account { pmset = new PwrMzrSettings(pm_enab, governor, levelbatt, levelac, sdoverr, OHSDEnabled, OHSDMemory, OHSDCore); } else { pmset = new PwrMzrSettings(pm_enab, governor, levelbatt, levelac); } return pmset; }
//Delete the powermizer Slowdown override Name/Value entries in the registry (Need a separate function because may want to delete this settings, //but no the original powermizer ones public void deletePowermizerSlowDownSettings() { if (this.nvidiaKey != null) { log("Deleting Powermizer Overheat SlowDown Override settings from the registry..."); try { //Let's extract the name of the keys from a settings struct PwrMzrSettings auxstruct = new PwrMzrSettings(PwrMzrValue.DEFAULT); if (this.regmgr.getDataValue(this.nvidiaKey, auxstruct.OverheatSlowdownEnabled.EntryName) != null) { logsub("Deleting..."); this.regmgr.deleteValue(this.nvidiaKey, auxstruct.OverheatSlowdownEnabled.EntryName); } if (this.regmgr.getDataValue(this.nvidiaKey, auxstruct.OverheatSlowdownMemory.EntryName) != null) { logsub("Deleting..."); this.regmgr.deleteValue(this.nvidiaKey, auxstruct.OverheatSlowdownMemory.EntryName); } if (this.regmgr.getDataValue(this.nvidiaKey, auxstruct.OverheatSlowdownCore.EntryName) != null) { logsub("Deleting..."); this.regmgr.deleteValue(this.nvidiaKey, auxstruct.OverheatSlowdownCore.EntryName); } //Flush the key for the changes to take effect this.regmgr.PersistKeyChanges(this.nvidiaKey); logsub("Success..."); //SLI/HYBRID SUPPORT if (Properties.Settings.Default.SLIModeEnabled == true) { if (this.regmgr.getDataValue(this.nvidiaSLIKey, auxstruct.OverheatSlowdownEnabled.EntryName) != null) { logsub("Deleting..."); this.regmgr.deleteValue(this.nvidiaSLIKey, auxstruct.OverheatSlowdownEnabled.EntryName); } if (this.regmgr.getDataValue(this.nvidiaSLIKey, auxstruct.OverheatSlowdownMemory.EntryName) != null) { logsub("Deleting..."); this.regmgr.deleteValue(this.nvidiaSLIKey, auxstruct.OverheatSlowdownMemory.EntryName); } if (this.regmgr.getDataValue(this.nvidiaSLIKey, auxstruct.OverheatSlowdownCore.EntryName) != null) { logsub("Deleting..."); this.regmgr.deleteValue(this.nvidiaSLIKey, auxstruct.OverheatSlowdownCore.EntryName); } //Flush the key for the changes to take effect this.regmgr.PersistKeyChanges(this.nvidiaSLIKey); logsub("Success... (SLIKey)."); } } catch { //All errors logged throw; } } }
//Read the prowermizer Settings public PwrMzrSettings readPowermizerSettings() { //Read the settings from the registry log("Extracting PowerMizer settings..."); object enab, gov, batfix, acfix; object sdenab, sdmem, sdcore; bool sdoverr = false; try { //Let's extract the name of the keys from a settings struct PwrMzrSettings auxstruct = new PwrMzrSettings(PwrMzrValue.DEFAULT); enab = regmgr.getDataValue(this.nvidiaKey, auxstruct.PowerMizerEnabled.EntryName); gov = regmgr.getDataValue(this.nvidiaKey, auxstruct.PowerMizerGovernor.EntryName); batfix = regmgr.getDataValue(this.nvidiaKey, auxstruct.PowerMizerBatteryFixedLevel.EntryName); acfix = regmgr.getDataValue(this.nvidiaKey, auxstruct.PowerMizerACFixedLevel.EntryName); //This settings may not be there! sdenab = regmgr.getDataValue(this.nvidiaKey, auxstruct.OverheatSlowdownEnabled.EntryName); sdmem = regmgr.getDataValue(this.nvidiaKey, auxstruct.OverheatSlowdownMemory.EntryName); sdcore = regmgr.getDataValue(this.nvidiaKey, auxstruct.OverheatSlowdownCore.EntryName); } catch { logsub("There were some major problems while reading the PowerMizer Settings."); throw; } //Patch in 0.95. Detect inconsistet registry keys caused by playing with different driver versions. //In some rare cases, the PerfLevelSrc entry is there, but the others are not, leading to strange situations. This provides a way out. if ((enab == null) || (gov == null) || (batfix == null) || (acfix == null)) { logsub("Your Registry settings seem to be inconsistent. You have **SOME** of the required entries for PowerMizer Management, but strangely enough, not **ALL** of them.This can be caused by installing/uninstalling several different drivers versions."); logsub("Please click the [Delete Powermizer Settings] button, and then on [Create Powermizer Settings] button again. This should solve the trouble. In case it does not, please send debug info to devs through the [Problems?] button."); throw new Exception(); } logsub("Success..."); //Create the settings structure (convert from object to the enumtype) PwrMzrValue governor = (PwrMzrValue)Enum.ToObject(typeof(PwrMzrValue), gov); PwrMzrValue levelbatt = (PwrMzrValue)Enum.ToObject(typeof(PwrMzrValue), batfix); PwrMzrValue levelac = (PwrMzrValue)Enum.ToObject(typeof(PwrMzrValue), acfix); PwrMzrValue pm_enab; if (Convert.ToBoolean(enab)) { pm_enab = PwrMzrValue.PM_ENABLED; logsub("Powermizer is ENABLED."); } else { pm_enab = PwrMzrValue.PM_DISABLED; logsub("Powermizer is DISABLED."); } logsub("Actual Governor: " + governor.ToString()); logsub("Actual Fixed Batt Level: " + levelbatt.ToString()); logsub("Actual Fixed AC Level: " + levelac.ToString()); //This settings may not be there, so we may have a bunch if nulls. Careful! PwrMzrValue OHSDEnabled = PwrMzrValue.PM_DISABLED, OHSDMemory = PwrMzrValue.PM_DISABLED, OHSDCore = PwrMzrValue.PM_DISABLED; if (sdenab != null) { sdoverr = true; logsub("Overheat Slowdown settings are OVERRIDEN..."); if (Convert.ToBoolean(sdenab)) { OHSDEnabled = PwrMzrValue.PM_ENABLED; logsub("Overheat Slowdown is ENABLED."); } else { OHSDEnabled = PwrMzrValue.PM_DISABLED; logsub("Overheat Slowdown is DISABLED."); } if (Convert.ToBoolean(sdmem)) { OHSDMemory = PwrMzrValue.PM_ENABLED; logsub("Overheat MEMORY Slowdown is ENABLED."); } else { OHSDMemory = PwrMzrValue.PM_DISABLED; logsub("Overheat MEMORY Slowdown is DISABLED."); } if (Convert.ToBoolean(sdcore)) { OHSDCore = PwrMzrValue.PM_ENABLED; logsub("Overheat CORE Slowdown is ENABLED."); } else { OHSDCore = PwrMzrValue.PM_DISABLED; logsub("Overheat CORE Slowdown is DISABLED."); } } else { sdoverr = false; logsub("No Overheat Slowdown settings found..."); } //Create the settings to return them PwrMzrSettings pmset; if (sdoverr) //IF we have detected overriden settings we need to take them into account { pmset = new PwrMzrSettings(pm_enab, governor, levelbatt, levelac, sdoverr, OHSDEnabled, OHSDMemory, OHSDCore); } else { pmset = new PwrMzrSettings(pm_enab, governor, levelbatt, levelac); } return(pmset); }