using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms; namespace Demo
{
static class Program
{
/// <summary>
/// 用于判断程序是否有重复启动的互斥量
/// </summary>
static System.Threading.Mutex _mutex; /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{ //是否可以打开新进程
bool createNew; /// 获取程序集Guid作为唯一标识,禁止程序重复启动
Attribute guid_attr = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(GuidAttribute));
string guid = ((GuidAttribute)guid_attr).Value;
_mutex = new System.Threading.Mutex(true, guid, out createNew); if (false == createNew)
{
MessageBox.Show("程序已在本机运行,不能重复运行!", "系统消息");
Application.Exit();
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
_mutex.ReleaseMutex();
Application.Run(new FrmMain());
}
}
}
}

最新文章

  1. WPF的路由事件、冒泡事件、隧道事件(预览事件)
  2. 抛弃msvcrtXX库
  3. kafka_2.11-0.8.2.2的搭建
  4. 【Sqlserver】修改数据库表中的数据:对缺失的数据根据已有的数据进行修补
  5. u-boot Makefile Source Test
  6. Winform Windows Media Player 简易播放器 分类: WinForm 2014-07-31 20:12 589人阅读 评论(0) 收藏
  7. Linux下运行C++程序出现&quot;段错误(核心已转储)&quot;的原因
  8. 2048 Puzzle游戏攻略
  9. 倒计时(距离活动结束还有X天X小时X分X秒)
  10. Centos7安装Percona5.7
  11. npm常用命令及版本号浅析
  12. jvm性能优化及内存分区
  13. 【转】Reflector、reflexil、De4Dot、IL相关操作指令合集
  14. IC5141安装备忘
  15. 如何使用Ubuntu中的avdManager命令行为“System-Image;Androd-27;GoogleAPI;x86”创建一个AVD?
  16. mysql中查看数据库的版本,什么版本
  17. 超全面的JavaWeb笔记day23&lt;AJAX&gt;
  18. cf1088D. Ehab and another another xor problem(思维)
  19. Apache Spark 2.0三种API的传说:RDD、DataFrame和Dataset
  20. tp.c

热门文章

  1. 小记--------maxwell启动失败解决
  2. 解决mac启动springboot项目很慢的问题
  3. Spring4学习回顾之路02—IOC&amp;DI
  4. 今天测试大商创,遇到了 upstream sent too big header while reading response header from upstream
  5. Windows 安装和配置 WSL
  6. Java super与this
  7. 作业6:Java虚拟机类加载机制
  8. Yali7月集训Contest2 T1 Cube 题解
  9. O037、Rebuild Instance 操作详解
  10. 这是一个用于判断IE浏览器版本的紧凑脚本