作者:寒江独垂
转自:http://blog.163.com/tianjunqiang666@126/blog/static/8725911920121026102111929/
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
using AirPort;
namespace AirPort
{
class AirMain_Hide
{
[DllImport("coredll.dll", EntryPoint = "FindWindow")]
public static extern int FindWindow(string lpWindowName, string lpClassName);
[DllImport("coredll.dll", EntryPoint = "ShowWindow")]
public static extern int ShowWindow(int hwnd, int nCmdShow);
[DllImport("coredll.dll", EntryPoint = "SystemParametersInfo")]
private static extern int SystemParametersInfo(int uAction, int uParam, ref Rectangle lpvParam, int fuWinIni);
public const int SW_SHOW = 5; //显示窗口常量
public const int SW_HIDE = 0; //隐藏窗口常量
public const int SPI_SETWORKAREA = 47;
public const int SPI_GETWORKAREA = 48;
public const int SPIF_UPDATEINIFILE = 0x01;
public bool HideTaskBar(bool FLAG)
{
int Hwnd = FindWindow("HHTaskBar", null);
if (Hwnd == 0) return false;
else
{
if (FLAG)
{
ShowWindow(Hwnd, SW_HIDE);
//Rectangle rectOld = new Rectangle();
Rectangle rectFull = Screen.PrimaryScreen.Bounds;
//SystemParametersInfo(SPI_GETWORKAREA, 0, ref rectOld, SPIF_UPDATEINIFILE);//get
SystemParametersInfo(SPI_SETWORKAREA, 0, ref rectFull, SPIF_UPDATEINIFILE);//set
}
else
{
ShowWindow(Hwnd, SW_SHOW);
}
}
return true;
}
}
}
由于本人使用到的只需要全屏显示永不退出,因此没有切换回来
自行参考
http://hi.baidu.com/w360186737/item/722c1ebb06070ff362388efa
http://blog.csdn.net/xmcokboy4/article/details/7586417
http://bbs.csdn.net/topics/270057756