首页 >> 文档 >> C#专题

C#隐藏系统任务栏的方法

发布日期:2008-07-03最近更新:2008-07-03来源:BHCODE作者:

昨天有个朋友问我如何用C#实现隐藏系统任务栏,网上搜索了一大堆,觉得下面这个C#写的代码不错,可以实现隐藏系统任务栏:

以下是C#隐藏系统任务栏的代码:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

 

using System.Runtime.InteropServices;

 

namespace TaskbarSwitch

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        [DllImport("coredll.dll")]

        private static extern int FindWindow(string lpClassName, string lpWindowName);

 

        [DllImport("coredll.dll")]

        internal extern static int EnableWindow(int hwnd, int fEnable);

 

        [DllImport("coredll.dll")]

        public static extern int ShowWindow(int hwnd, int nCmdShow);

 

        private void Form1_Load(object sender, EventArgs e)

        {

            //屏蔽系统任务栏

            int hTaskBarWnd = FindWindow("HHTaskBar", null);

            ShowWindow(hTaskBarWnd, 0);

 

            this.Size = new Size(240, 240);

        }

 

        private void Form1_Closed(object sender, EventArgs e)

        {

            //屏蔽系统任务栏

            int hTaskBarWnd = FindWindow("HHTaskBar", null);

            ShowWindow(hTaskBarWnd, 1);

        }

    }

}

本周推荐
MORE
热点关注
MORE