zu14 发表于 2013-2-7 04:47:36

C#使用Windows API 隐藏/显示 任务栏 (FindWindowEx, ShowWindow)

   今天,有网友询问,如何显示和隐藏任务栏?
我这里,发布一下使用Windows API 显示和隐藏 Windows 的任务栏的方法,windows 的任务栏,其实是一个窗口(window),只要找到这个窗口的句柄,显示和隐藏就轻而易举了,任务栏是个没有标题的窗口,但它的类名是 Shell_TrayWnd,所以,可以用FindWindow 或 FindWindowEx 去查找它的句柄,而显示和隐藏窗口,使用的是 ShowWindow:


[*]引入Windows API 的声明
<div class="wp_codebox">   [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);
页: [1]
查看完整版本: C#使用Windows API 隐藏/显示 任务栏 (FindWindowEx, ShowWindow)