有没有办法更改Windows浏览器的任务栏图标?
-
21-08-2019 - |
题
是否有任何的方式来改变在窗口浏览器的任务栏图标?
我打开很多的浏览器窗口,我喜欢组类似的网站(在标签中)通过窗口。所以我在想,如果有一个任务栏图标分配给他们,让您可以在它们之间更容易区分的方式。
解决方案
这里的东西我放在一起在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);
}
其他提示
相信在任务栏使用嵌入的可执行图标资源。我试图创建多个快捷方式到Internet Explorer,每一个独特的快捷方式图标,但他们都有相同的图标在任务栏上打开的时候。
我想你可以运行浏览器可执行文件的多个实例,每个就必须有不同的嵌入式图标资源。
不隶属于 StackOverflow