实现效果:
知识运用:
〔HungAppTimeout〕是關閉應用程式的等待時間
〔WaitToKillServiceTimeout〕是關閉windows服務的等待時間
实现代码:
private void button1_Click(object sender, EventArgs e) { try { RegistryKey rk = Registry.CurrentUser.CreateSubKey("Control Panel\Desktop"); rk.SetValue("HungAppTimeout",400); rk.SetValue("WaitToKillAppTimeout", 1000); Registry.SetValue(@"HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControl", "HungAppTimeout", 400); Registry.SetValue(@"HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControl", "WaitToKillAppTimeout", 1000); MessageBox.Show("优化已完成!从新启动后生效"); } catch (Exception) { MessageBox.Show("此程序不适用于你的操作系统"); } }