using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms; namespace WindowsFormsApplication4
{
public class MultiRunChecker{ public static bool hasMultiRun()
{ Process[] ps = Process.GetProcessesByName(Assembly.GetExecutingAssembly().GetName().Name);
if (ps != null && ps.Length > 1)
{ //发现重复进程
return true;
} return false; }
}
} 调用:
//防止改名运行
if (!Application.ExecutablePath.EndsWith(Assembly.GetExecutingAssembly().GetName().Name+".exe")) {
MessageBox.Show("app not valid");
Application.Exit();
} if (MultiRunChecker.hasMultiRun()) {、、防止多个程序运行 MessageBox.Show("has");
Application.Exit(); }

  

最新文章

  1. @SuppressWarnings注解的用法
  2. 安装AutoCAD2006时,提示已终止安装
  3. javascript_core_08之闭包、对象、原型
  4. FZU1894 单调队列
  5. 泛函编程(24)-泛函数据类型-Monad, monadic programming
  6. epoll函数与参数总结学习 & errno的线程安全
  7. 【转】iOS中定时器NSTimer的使用
  8. SQL语句的增删改查
  9. CSS:margin负数的使用
  10. PHP 的解压缩ZipArchive中的extractTo()方法 LINUX+nginx环境中解压zip时文件丢失的问题
  11. VS2010下编译sqlite3
  12. Linux关机重启指令
  13. 【Node.js】利用node.js搭建服务器并访问静态网页
  14. yield学习笔记
  15. ACM:日历本
  16. docker php容器中简单添加seaslog拓展
  17. windowsserver2019系统下载
  18. ajax验证用户名是否被注册 ; ajax提交form表单
  19. sixsix团队“餐站”应用代码规范及开发文档
  20. FactoryMethod工厂方法模式(创建型模式)

热门文章

  1. SD从零开始05-06
  2. 如何通过REST API登录Portal for ArcGIS
  3. springcloud 入门 3 (服务之间的调用)
  4. 今日面试WPS总结
  5. hashCode()与equals()方法的对比
  6. alpha阶段 代码结构及技术难点简介
  7. crontab 命令使用
  8. Spark job 部署模式
  9. [Python] 同时安装了python2和python3时,pip命令该如何使用?
  10. 【Ansible 文档】【译文】Windows 支持