隐藏windows任务栏
using Microsoft.Win32;
using System.Runtime.InteropServices;
class TaskBar
{
[DllImport("user32.dll", EntryPoint = "FindWindowA")]
public static extern IntPtr FindWindowA(string lp1, string lp2);
[DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", EntryPoint = "ShowWindow")]
public static extern IntPtr ShowWindow(IntPtr hWnd, int _value);
/// 是否显示任务栏
/// </summary>
/// <param name="i">1=显示 0=隐藏</param>
public static void ShieldTaskBar(int i)
{
try
{
IntPtr hTray = FindWindowA("Shell_TrayWnd", String.Empty);
ShowWindow(hTray, i);
IntPtr hStar = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Button", null);
ShowWindow(hStar, i);
}
catch (Exception ex)
{
Log.Write("操作任务栏出错", ex);
}
}
}
浙公网安备 33010602011771号