- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- namespace TaskBar
- {
- public partial class Form1 : Form
- {
- [DllImport("user32.dll")]
- public static extern int ShowWindow(int hwnd, int nCmdShow);
- [DllImport("user32.dll")]
- public static extern int FindWindow(string lpClassName,string lpWindowName);
- //隐藏任务栏
- private const int SW_HIDE = 0;
- //显示任务栏
- private const int SW_RESTORE = 9;
- public Form1()
- {
- InitializeComponent();
- }
- private void show_Click(object sender, EventArgs e)
- {
- ShowWindow(FindWindow("Shell_TrayWnd", null), SW_RESTORE);
- }
- private void hide_Click(object sender, EventArgs e)
- {
- ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE);
- }
- }
- }
参考文献: