•引入Windows API 的声明 [DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);[DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)]
static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow); <script type="text/javascript"><!-- google_ad_client = "pub-5834986413902221"; /* 728x90 */ google_ad_slot = "1368486102"; google_ad_width = 728; google_ad_height = 90; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> •显示/隐藏任务栏窗口 IntPtr trayHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
if (trayHwnd != IntPtr.Zero)
{
    ShowWindow(trayHwnd, 0);

上面的代码中, ShowWindow 的第二参数, 1 表示显示, 0 表示隐藏

解决方案 »

  1.   

            [System.Runtime .InteropServices .DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)]
            static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);        [System.Runtime .InteropServices .DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)]
            static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);
            /// <summary>
            ///  SetTaskBar  1 表示显示, 0 表示隐藏
            /// </summary>
            /// <param name="istate"></param>
            public static void SetTaskBar(uint istate)
            {
                IntPtr trayHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
                if (trayHwnd != IntPtr.Zero)
                {
                    ShowWindow(trayHwnd, istate);
                }        }
      

  2.   

    楼上的大哥 不知道你是否有验证过你发的代码,还是直接GOOGLE上搜到就贴过来了,Google我也会用,只是实在找不到方法才来发帖请教各位的。这个代码在XP下的确有效 ,在WIN7下只能隐藏任务栏,开始按钮却还在。
      

  3.   

    我验证了兄弟        public static void SetTaskBar(uint istate)
            {
                IntPtr trayHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
                IntPtr hStar = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Button", null);
                if (trayHwnd != IntPtr.Zero && hStar!=IntPtr.Zero)
                {
                    ShowWindow(trayHwnd, istate);
                    ShowWindow(hStar, istate);
                }        }
    把那个方法改了
    就可以隐藏开始按钮咯
      

  4.   

    非常感谢Tsapi!!!哈哈!!
      

  5.   

    可以实现,非常感谢,我贴上C++源码(隐藏的话,换为SW_HIDE)HWND WndHandle;
    // 获取任务栏的窗口句柄,并显示
    WndHandle = FindWindow(_T("Shell_TrayWnd"), NULL);
    ShowWindow(WndHandle, SW_SHOW);
    HWND WndHandle2;
    // 获取开始按钮句柄,并显示
    WndHandle2 = FindWindow(_T("Button"), NULL);
    ShowWindow(WndHandle2, SW_SHOW);