现在的位置: 首页 > 综合 > 正文

通过win32api让c#控制Windows任务栏

2013年03月02日 ⁄ 综合 ⁄ 共 777字 ⁄ 字号 评论关闭
 

如果你要在你的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);

做人要厚道,请注明转自酷网动力(www.ASPCOOL.COM)。


抱歉!评论已关闭.