C#程序中控制Windows的任务栏

如果你要在你的C#程序中控制Windows的任务栏,有两个Windows api 可以帮到你!他们就是  FindWindowA 和 ShowWindow

C#中声明如下:

using System.Runtime.InteropServices;

[DllImport("user32.dll", EntryPoint = "FindWindowA")]
public static extern IntPtr FindWindowA(string lp1, string lp2);

[DllImport("user32.dll", EntryPoint = "ShowWindow")]
public static extern IntPtr ShowWindow(IntPtr hWnd, int _value);

其实Windows的任务栏就是一个特殊的窗口,所以操作窗口的方法,对任务栏一样适合!控制代码如下:

//获取任务栏
IntPtr hTray = Form1.FindWindowA("Shell_TrayWnd", String.Empty);

//显示任务栏
Form1.ShowWindow(hTray, 5);

//隐藏任务栏
Form1.ShowWindow(hTray, 0);

posted on 2008-07-10 17:51  那片云  阅读(339)  评论(0编辑  收藏  举报

导航