有没有办法在Windows中更改浏览器的任务栏图标?

时间:2008-12-10 17:27:58

标签: internet-explorer firefox browser add-in taskbar

有没有办法在Windows中更改浏览器的任务栏图标?

我打开很多浏览器窗口,我喜欢按窗口分组类似的网站(在标签中)。所以我想知道是否有办法为它们分配任务栏图标,以便您可以更容易地区分它们。

2 个答案:

答案 0 :(得分:5)

这是我在5分钟内组合在一起以更改特定窗口上的图标的内容。您可以轻松地使用此代码创建一个winform,它将枚举当前打开的窗口,并允许您为它们分配任意图标。 (下面的C#代码)

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr FindWindow(string strClassName, string strWindowName);

[DllImport("user32.dll",CharSet=CharSet.Auto)]  
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam); 

[DllImport("user32.dll")] 
public static extern int DrawMenuBar(int currentWindow);


const int WM_GETICON = 0x7F;
const int WM_SETICON = 0x80;
const int ICON_SMALL = 0; //16
const int ICON_BIG = 1; //32

public static void SetIcon()
{
    //Load an icon. This has to be a *.ico.
    System.Drawing.Icon i = new Icon("path\to\icon");
    //Find the target window. The caption must be entered exactly 
    //as it appears in the title bar
    IntPtr hwnd = FindWindow(null, "Caption of Target Window");
    //Set the icon
    SendMessage(hwnd, WM_SETICON, (IntPtr)ICON_SMALL, (IntPtr)i.Handle);
    //Update the title bar with the new icon. Note: the taskbar will
    //update without this, you only need this if you want the title
    //bar to also display the new icon
    DrawMenuBar((int)hwnd);
}

答案 1 :(得分:1)

我相信任务栏使用可执行文件中嵌入的图标资源。我尝试创建多个Internet Explorer快捷方式,每个快捷方式都有一个独特的快捷方式图标,但在任务栏上打开时它们都有相同的图标。

我认为您必须运行浏览器可执行文件的多个实例,并且每个实例都必须具有不同的嵌入式图标资源。