您的位置:首页 > 编程语言 > C#

利用c#制作托盘程序,并禁止多个应用实例运行

2007-12-30 17:37 701 查看
托盘程序的制作:

1.把NotifyIcon控件拉一个到窗体上,并设置NotifyIcon的Icon(很重要!否则运行后看不到效果)

2.窗体关闭时,将程序最小化到系统托盘上

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

private void menuShow_Click(object sender, EventArgs e)

private void menuExit_Click(object sender, EventArgs e)

private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)

using System;

using System.Collections.Generic;

using System.Windows.Forms;

using System.Threading;

namespace LuceneTest

{

static class Program

{

/**//// <summary>

/// 应用程序的主入口点。

/// </summary>

[STAThread]

static void Main()

{

bool bCreatedNew;

Mutex m = new Mutex(false, "Product_Index_Cntvs", out bCreatedNew);

if (bCreatedNew)

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form1());

}

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: