C#关于如何在任务栏中隐藏和显示其它应用程序的图标

来源:互联网 发布:淘宝代销和分销的区别 编辑:程序博客网 时间:2024/05/22 01:34

这几天无聊玩游戏,又怕老婆不能让她看到玩游戏,给自己设置了一个隐藏游戏程序名称的小程序。在网上看到不少人都有这想法又没看到几个可用的,有位大神隐藏了QQ程序这里也给个链接:http://www.csframework.com/archive/2/arc-2-20110712-1687.htm

我这里也给个别人要找的链接:http://bbs.csdn.net/topics/340144066?page=1#post-393338580这个没成功结帖。

直接上代码:

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 joke{    public partial class Form1 : Form    {        [DllImport("user32.dll")]        private static extern int FindWindow(String className, String WindowText);        [DllImport("user32.dll")]        private static extern int ShowWindow(int hwnd, int command);        private const int Sw_Hide = 0;        private const int Sw_Show = 1;        protected static int Handle            //隐藏了继承的成员这里有个提示,没有搞清楚有大侠给个意见修改下。        {            get            {                return FindWindow("Sword3 Class", "剑侠情缘·网络版");            }        }        public Form1()        {            InitializeComponent();        }               private void toolStripButton1_Click(object sender, EventArgs e)        {            ShowWindow(Handle, Sw_Hide);        }        private void toolStripButton2_Click(object sender, EventArgs e)        {            ShowWindow(Handle, Sw_Show);        }    }}


原创粉丝点击