C# Window7任务栏缩略图小工具

程序的实现原理:
 
 在注册表目录HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband下新建几个键:MaxThumbSizePx, MinThumbSizePx, ThumbSpacingXPx, ThumbSpacingYPx, TopMarginPx, BottomMarginPx, LeftMarginPx, RightMarginPx 分别用于控制缩略图尺寸, 两个缩略图直接的边距, 还有缩略图中内容的上下左右边距
  在注册表目录HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced下新建一个键: ExtendedUIHoverTime
它用于控制缩略图显示的延迟时间(单位是ms)
  每次更改完注册表的信息后, 要看到效果不需要重新开机, 只需要关闭explore.exe, 再重新打开即可.
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;    //要用Registry类
using System.Diagnostics;//要用Prcess类

namespace Win7任务栏缩略图工具
{
        public partial class Win7TaskBar : Form
        {
                public Win7TaskBar()
                {
                        InitializeComponent();
                }

                
 
                private void trackBar1_Scroll(object sender, EventArgs e)
                {
                        textBox1.Text = trackBar1.Value.ToString ();
                }

                private void trackBar2_Scroll(object sender, EventArgs e)
                {
                        textBox2.Text = trackBar2.Value.ToString();
                }

                private void trackBar3_Scroll(object sender, EventArgs e)
                {
                        textBox3.Text = trackBar3.Value.ToString();
                }

                private void trackBar4_Scroll(object sender, EventArgs e)
                {
                        textBox4.Text = trackBar4.Value.ToString();
                }

                private void trackBar5_Scroll(object sender, EventArgs e)
                {
                        textBox5.Text = trackBar5.Value.ToString();
                }

                private void trackBar6_Scroll(object sender, EventArgs e)
                {
                        textBox6.Text = trackBar6.Value.ToString();
                }

                private void trackBar7_Scroll(object sender, EventArgs e)
                {
                        textBox7.Text = trackBar7.Value.ToString();
                }

                private void trackBar8_Scroll(object sender, EventArgs e)
                {
                        textBox8.Text = trackBar8.Value.ToString();
                }
 
                private void trackBar9_Scroll(object sender, EventArgs e)
                {
                        textBox9.Text = trackBar9.Value.ToString();
                }
        
        
                private void btnOK_Click(object sender, EventArgs e)
                {
                        string RegTimepath = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced";
                        string RegTaskbarpath = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband";
                        string[] names = { "MaxThumbSizePx", "MinThumbSizePx", "ThumbSpacingXPx", "ThumbSpacingYPx", "TopMarginPx", "BottomMarginPx", "LeftMarginPx", "RightMarginPx" };
                        int [] values = { trackBar1.Value ,trackBar2.Value ,trackBar3.Value ,trackBar4.Value ,trackBar5 .Value ,trackBar6 .Value ,trackBar7 .Value ,trackBar8 .Value ,trackBar9.Value };
                        for(int i=0;i<=7;i++)
                        {
                        Registry.SetValue(RegTaskbarpath ,names[i],values[i],RegistryValueKind.DWord);
                        }
                        Registry.SetValue(RegTimepath, "ExtendedUIHoverTime",trackBar9.Value,RegistryValueKind.DWord    );
                        Process[] explorers = Process.GetProcessesByName("explorer");
                        foreach (Process ex in explorers)    
                        {
                                ex.Kill();
                        }
                        Process.Start("explorer.exe");
                        explorers = null;
                }

                private void btnRestore_Click(object sender, EventArgs e)
                {
                        string RegTimepath = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced";
                        string RegTaskbarpath = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband";
                        string[] names = { "MaxThumbSizePx", "MinThumbSizePx", "ThumbSpacingXPx", "ThumbSpacingYPx", "TopMarginPx", "BottomMarginPx", "LeftMarginPx", "RightMarginPx" };
                        for(int    i=0;i<=1;i++)
                        {
                             Registry.SetValue(RegTaskbarpath ,names [i],200, RegistryValueKind.DWord );
                        }
                        for (int i = 2; i <= 7; i++)
                        {
                                Registry.SetValue(RegTaskbarpath, names[i], 16, RegistryValueKind.DWord);
                        }
                        Registry.SetValue(RegTimepath, "ExtendedUIHoverTime", 400, RegistryValueKind.DWord);    
//重新启动explorer.exe
Process[] explorers = Process.GetProcessesByName("explorer");
                        foreach (Process ex in explorers)
                        {
                                ex.Kill();
                        }
                        Process.Start("explorer.exe");
                        explorers = null;
                }

                private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
                {
                        Process.Start("http://www.cnblogs.com/xspaceworld/");//这是我的博客园的博客 ,欢迎大家光临!
                }
        
        }
}
实现效果图:
posted @ 2011-03-01 17:49  X-Space  阅读(1755)  评论(0编辑  收藏  举报