반응형
        public const int MIN_ALL = 0x01A3;
        public const int MIN_ALL_UNDO = 0x01A0;
        public const int WM_COMMAND = 0x0111;
        
        [DllImport("User32.dll", EntryPoint = "FindWindow")]
        public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);

        [DllImport("User32.dll", CharSet = CharSet.Auto, EntryPoint = "SendMessage")]
        public static extern int SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam);

        public static void SendMinimizeAllWindows(bool bMinimize)
        {
            IntPtr lHwnd = FindWindow("Shell_TrayWnd", null);
            if (bMinimize)
            {
                SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL, IntPtr.Zero);
            }
            else
            {
                SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL_UNDO, IntPtr.Zero);
            }
        }
반응형

+ Recent posts