如何限制用户只打开一次Windows应用程序 [英] how can restrict the user to open windows application only once
本文介绍了如何限制用户只打开一次Windows应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何限制用户只打开Windows应用程序单个实例
how can restrict the user to open windows application only single instance
推荐答案
尝试在"Program.cs"中添加以下代码。
Try to add the following code in "Program.cs".
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bool blnIsRunning;
Mutex mutexApp = new Mutex(false, Assembly.GetExecutingAssembly().FullName, out blnIsRunning);
if (!blnIsRunning)
{
MessageBox.Show("Is Running!", "Warning",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
Application.Run(new Form1());
}
结果:
问候,
Kyle
这篇关于如何限制用户只打开一次Windows应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文