设置只能开启一个程序实例
Posted jizhiqiliao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了设置只能开启一个程序实例相关的知识,希望对你有一定的参考价值。
在“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()); }
测试结果:
以上是关于设置只能开启一个程序实例的主要内容,如果未能解决你的问题,请参考以下文章
我在哪里更改此 Python 代码片段以将临时文件保存在 tmp 文件夹中?
如何为 XSLT 代码片段配置 CruiseControl 的 C# 版本?
Android 逆向使用 Python 解析 ELF 文件 ( Capstone 反汇编 ELF 文件中的机器码数据 | 创建反汇编解析器实例对象 | 设置汇编解析器显示细节 )(代码片段