kenlistian

勤学多思

  IT博客 :: 首页 :: 新随笔 ::  :: 聚合  :: 管理 ::
  412 随笔 :: 0 文章 :: 23 评论 :: 0 Trackbacks

        private const int SWP_HIDEWINDOW = 0x80;
        private const int SWP_SHOWWINDOW = 0x40; 

        [DllImport("user32", EntryPoint = "SetWindowPos")]
        public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndlnsertAfter, int X, int Y, int cx, int cy, int flags); 
        [DllImport("User32.dll")]
        public static extern IntPtr FindWindowEx(IntPtr ph, IntPtr ch, String cn, String wn);
        [DllImport("User32.dll")]
        public static extern bool ShowWindow(IntPtr hWnd, long nCmdShow );

        private static void  HideTaskWindow(bool bHide)
        {
            if (bHide)
            {
                IntPtr handle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
                //ShowWindow(handle, 0);
                SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0,SWP_HIDEWINDOW); 
            }
            else
            {
                IntPtr handle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
                //ShowWindow(handle, 5);
                SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SWP_SHOWWINDOW);
            }            
        }
posted on 2013-05-10 14:11 kenlistian 阅读(565) 评论(0)  编辑 收藏 引用 所属分类: csharp
只有注册用户登录后才能发表评论。