本篇展示兩個實用的 IE 客製化範例:啟用視窗動畫效果、變更工具列背景圖片。
using System;
using Microsoft.Win32;
namespace ChangeIE
{
class Program
{
[STAThread]
static void Main(string[] args)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(
@"Control Panel\Desktop\WindowMetrics", true);
if (key == null)
{
Console.WriteLine("鍵值不存在");
}
else
{
key.SetValue("MinAnimate", "1");
key.SetValue("MaxAnimate", "1");
Console.WriteLine("修改成功");
}
key.Close();
}
}
}
修改 HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics 下的 MinAnimate 與 MaxAnimate 為 1 即可啟用動畫過渡效果。
using System;
using Microsoft.Win32;
namespace ChangeIEbackColor
{
class Program
{
[STAThread]
static void Main(string[] args)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(
@"Software\Microsoft\Internet Explorer\Toolbar\Explorer", true);
if (key == null)
{
Console.WriteLine("鍵值不存在");
}
else
{
key.SetValue("BackBitmap", @"C:\Windows\Greenstone.bmp");
Console.WriteLine("修改成功");
}
key.Close();
}
}
}
在 HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar\Explorer 新增 BackBitmap 字串值,指定 BMP 完整路徑。
登錄表操作有風險:修改前務必備份,錯誤操作可能導致系統不穩定。建議在測試環境驗證後再部署生產機。
開發環境:Windows Server 2003 + VS.NET 2003 測試通過。