判断程序是否已启动
来源:互联网 发布:sql 除后求和 编辑:程序博客网 时间:2024/06/05 16:27
方法1:using System;using System.Collections.Generic;using System.Linq;using System.Windows.Forms;using System.Diagnostics;namespace MonitorHardDisk{ static class Program { private static System.Threading.Mutex mutex; /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mutex = new System.Threading.Mutex(true, "OnlyRun"); if (mutex.WaitOne(0, false)) { Application.Run(new Form1()); } else { MessageBox.Show("程序已经在运行!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit(); } } }}方法2: #region 禁止多进程启动控制 bool b; Mutex m = new Mutex(true, "PharmeyesDDIWinUIThreadCs", out b); int i = 0; foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses()) { if ("Pharmeyes.DDI.WinUI".ToLower().Equals(p.ProcessName.ToString().ToLower())) { i++; } } if (!b || i > 1) { log.Info(string.Format("程序在系统进程中已存在!....................................")); return; } #endregion
0 0
- 判断程序是否已启动
- C#判断程序自己是否已启动
- Android 判断程序是否已安装 & 启动另一个程序
- 判断app是否已启动
- 判断Android模拟器是否已完全启动
- sh 脚本判断 tomcat是否已启动
- VC 判断程序是否启动.
- 用互斥量来判断程序是否已运行
- VC中判断程序是否已运行
- App判断程序是否第一次启动
- Android判断程序是否第一次启动
- ios 程序判断是否第一次启动
- ios 程序判断是否第一次启动
- 判断程序是否是第一次启动
- Android 判断程序是否是第一次启动
- 安卓判断是否第一次启动程序
- 判断该程序是否已有实例运行
- C# 判断某程序是否运行,已运行则激活
- 常用的python package下载(windows)
- Android多媒体开发【10】-- android中OpenMax的实现【1】整体框架
- NYOJ--1009 So Easy[Ⅰ]
- WKT 格式
- 存储过程里出错:在将 nvarchar 值 'MAX' 转换成数据类型 smallint 时失败, 的终极解决方法
- 判断程序是否已启动
- Lua脚本在C++下的舞步(入门指引)转
- 产品设计中的交互工具
- 【C语言天天练(十六)】字符串输出函数puts、fputs和printf
- Android多媒体开发【11】-- android中OpenMax的实现【2】AwesomePlayer中openmax的入口
- 用js截取字符串
- redmine备份和还原
- C#字符串处理
- DispatchAction 的使用