admin 管理员组

文章数量: 1184232

//话不多说,//大家互相交流,有不足处请指正

1.Form页面如下

2.代码如下

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 显示隐藏任务栏
{
public partial class Form1 : Form
{
private const int SW_HIDE = 0;  //隐藏任务栏
private const int SW_RESTORE = 9;//显示任务栏
[DllImport("user32.dll")]
public static extern int ShowWindow(int hwnd, int nCmdShow); //此为重点
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName, string lpWindowName); //此为重点

public Form1()
{
InitializeComponent();
}

private void button1_Show_Click(object sender, EventArgs e)
{
ShowWindow(FindWindow("Shell_TrayWnd", null), SW_RESTORE);
if (checkBox1.Checked == true)  //checkBox1选中状态,click后则控件关闭
{
this.Dispose();
this.Close();
}
}

private void button2_Hide_Click(object sender, EventArgs e)
{
ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE);
if (checkBox1.Checked == true) //checkBox1为选中状态时候,click后则控件关闭
{
this.Dispose();
this.Close();
}
}
}
}

本文标签: 系统 编程 关闭