有没有办法在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); }