All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
C#教程:通过注册表优化系统

Writer: qq Article type: Programming skills(编程技巧) Time: 2014/7/11 9:28:27 Browse times: 268 Comment times: 0

C#教程:通过注册表优化系统


Head photo

Go homepage
Upload pictures
Write articles

C#教程:通过注册表优化系统

通过注册表优化系统
随着用户为自己的计算机安装很多软件后会明显的发现“开/关”机的速度很慢,右键单击桌面时快捷菜单要等待几秒才能显示,下面通过操作注册表来解决该问题。
本实例通过RegistryKey类与Registry类对注册表中的键值进行写入与删除,实现通过注册表优化系统的功能,其中包括“加快开/关机速度”、“加快自动刷新率”、“加快菜单显示速度”等,程序运行结果如图1所示。
设置注册表中“HKEY_CURRENT_USER Control PanelDesktop”键下的“HungApp Timeout”值为400,将“WaitToKillAppTimeout”键的数值设置为1000,同时再把“HKEY_ LOCAL_ MACHINESystemCurrentControlSetControl”键下“HungAppTimeout”值设置为400,将字符串“WaitToKillServiceTimeout”的数值设置为1000。运行程序,如图15所示,鼠标左键单击【加快开/关机速度】按钮,重新启动计算机后,便可以得到理想的开关机效果。代码如下:
private void button1_Click(object sender, EventArgs e)
{
try
{
RegistryKey rgK = Registry.CurrentUser.CreateSubKey(@"Control PanelDesktop");
rgK.SetValue("HungAppTimeout", 400);
rgK.SetValue("WaitToKillAppTimeout", 1000);
Registry.SetValue(@"HKEY_LOCAL_MACHINESystem CurrentControlSetControl","HungAppTimeout", 400);
Registry.SetValue(@"HKEY_LOCAL_MACHINESystem CurrentControlSetControl", "WaitToKillServiceTimeout", 1000);
MessageBox.Show("修改成功--请重新启动计算机");
}
catch(Exception ey)
{
MessageBox.Show("这个程序可以不适合用户的操作系统");
}
}
为了节约刷新时的等待时间,可以通过设置注册表中的键值(“HKEY_LOCAL_MACHINE SystemCurrentControlSetControlUpdate”,将Dword“UpdateMode”的数值数据更改为“0”这里的值可以根据要求自己设置)实现。运行程序,如图37.15所示,单击【加快自动刷新率】按钮,重新启动计算机后,便可以加快自动刷新率。代码如下:
private void button2_Click(object sender, EventArgs e)
{
try
{
RegistryKey rgK = Registry.LocalMachine.CreateSubKey(@"SystemCurrentControlSetControlUpdate");
rgK.SetValue("UpdateMode", 0);
MessageBox.Show("修改成功--请重新启动计算机");
}
catch (Exception ey)
{
MessageBox.Show("这个程序可以不适合用户的操作系统");
}
}
加快菜单显示速度,可以通过设置注册表中的键值(“HKEY_CURRENT_USERControl PanelDesktop”,将字符串值“MenuShowDelay”的数值数据更改为“0”,调整后如果觉得菜单显示速度太快而不适应,可将“MenuShowDelay”的数值数据更改为“200”)实现。运行程序,如图37.15所示,单击【加快菜单显示速度】按钮,重新启动计算机后,便可以加快菜单的显示速度。代码如下:
private void button3_Click(object sender, EventArgs e)
{
try
{
RegistryKey rgK = Registry.CurrentUser.CreateSubKey(@"ControlPanelDesktop");
rgK.SetValue("MenuShowDelay", 0);//可以弄大些可以看出效果
MessageBox.Show("修改成功--请重新启动计算机");
}
catch (Exception ey)
{
MessageBox.Show("这个程序可以不适合用户的操作系统");
}
完整程序代码如下:
★ ★★★★Form1.cs窗体代码文件完整程序代码★★★★★
using System;
using System.Collections.Generic;
using System.ComponentModel;





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.