有没有办法改变Windows浏览器的任务栏图标?
我打开了很多浏览器窗口,并且喜欢按窗口对类似的网站(在选项卡中)进行分组。所以我想知道是否有一种方法可以为它们分配任务栏图标,以便您可以更轻松地区分它们。
最佳答案
这是我在 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 - 有没有办法改变windows浏览器任务栏图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/356883/