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/");//這是個人博客園的博客 ,歡迎你們光臨!
                }
        
        }
}
實現效果圖:
相關文章
相關標籤/搜索