⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 removeiconshelper.cs

📁 Hide-Delete icon from ToolBar32 for specific process , from command line arguments. TBBUTTON CSha
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HideSteamIcon
{
    using System.Runtime.InteropServices;

    class RemoveIconsHelper
    {
        
            public const int WM_USER = 0x0400;

            public const uint TB_HIDEBUTTON = WM_USER + 4;

            public const uint TB_DELETEBUTTON = WM_USER + 22;
            public const int TB_BUTTONCOUNT = WM_USER + 24;
            public const int TB_GETBUTTONINFO = WM_USER + 63;

            public const int TBIF_IMAGE = 0x0001;
            public const int TBIF_TEXT = 0x0002;
            public const int TBIF_STATE = 0x0004;
            public const int TBIF_STYLE = 0x0008;
            public const int TBIF_LPARAM = 0x0010;
            public const int TBIF_COMMAND = 0x0020;
            public const int TBIF_SIZE = 0x0040;
            public const uint TBIF_BYINDEX = 0x80000000;



            [StructLayout(LayoutKind.Sequential)]
            public struct TBBUTTONINFO
            {
                public uint cbSize;
                public uint dwMask;
                public int idCommand;
                public int iImage;
                public byte fsState;
                public byte fsStyle;
                public short cx;
                public IntPtr lParam;
                [MarshalAs(UnmanagedType.LPTStr)]
                public string lpszText;
                public int cchText;
            }

            [DllImport("user32.dll")]
            [return: MarshalAs(UnmanagedType.Bool)]
            public static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate,
                              IntPtr hrgnUpdate, uint flags);

            [DllImport("user32.dll", SetLastError = true)]
            public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

            [DllImport("user32.dll", SetLastError = true)]
            public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

            [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
            public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

            [DllImport("user32.dll", SetLastError = true)]
            public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, bool lParam);

            [DllImport("user32.dll", SetLastError = true)]
            public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);

            [DllImport("user32.dll", SetLastError = true)]
            public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, ref TBBUTTONINFO lParam);



            public static void DeleteAllTaskbarButtons()
            {
                IntPtr shellTrayHwnd = FindWindow("Shell_TrayWnd", null);
                IntPtr window = GetNotifyWindow();
                int count = (int)SendMessage(window, TB_BUTTONCOUNT, IntPtr.Zero, IntPtr.Zero);

                for (int i = 0; i < count; i++)
                {
                    SendMessage(window, TB_DELETEBUTTON, i, 0);
                }
            }


            public static IntPtr GetNotifyWindow()
            {
                IntPtr shellTrayHwnd = FindWindow("Shell_TrayWnd", null);
                IntPtr trayNotifyHwnd = FindWindowEx(shellTrayHwnd, IntPtr.Zero, "TrayNotifyWnd", null);
                IntPtr sysPagerHwnd = FindWindowEx(trayNotifyHwnd, IntPtr.Zero, "SysPager", null);
                return FindWindowEx(sysPagerHwnd, IntPtr.Zero, "ToolbarWindow32", null);
            }
        }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -