织梦CMS - 轻松建站从此开始!

罗索

当前位置: 主页>杂项技术>.NET(C#)>

C#如何确定一个进程的执行

jackyhwei 发布于 2011-05-26 09:38 点击:次 
C#判断一个进程是否处于执行中的代码实现。
TAG:

  1. using System; 
  2. using System.IO; 
  3. using System.Collections.Generic; 
  4. using System.Windows.Forms; 
  5. using System.Diagnostics; 
  6.  
  7. namespace WindowsApplication2MMS 
  8.     static class Program 
  9.     { 
  10.         private static bool IsExistProcess() 
  11.         { 
  12.             bool result = false
  13.             Process[] p = Process.GetProcessesByName(Path.GetFileNameWithoutExtension
  14. (Application.ExecutablePath)); 
  15.             if (p != null && p.Length > 1) 
  16.             { 
  17.                 result = true
  18.             } 
  19.             return result; 
  20.         }                     
  21.  
  22.    //    public Form1 mainform = null; 
  23.    //    public static SplashScreen loadfrom = new SplashScreen(); 
  24.         /// <summary> 
  25.         /// 应用程序的主入口点。 
  26.         /// </summary> 
  27.         [STAThread] 
  28.         static void Main() 
  29.         { 
  30.             Application.EnableVisualStyles(); 
  31.             Application.SetCompatibleTextRenderingDefault(false); 
  32.  
  33.             if (!IsExistProcess()) 
  34.                 Application.Run(new Form1()); 
  35.             else 
  36.                 Application.Exit(); 
  37.         //  Application.Run(new check()); 
  38.         //  Application.Run(new imageshow()); 
  39.         } 
  40.     } 


可参考http://www.cnblogs.com/Fooo/archive/2008/09/25/1298455.html

(dl-lzx)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201105/13182.html]
本文出处:dl-lzx.blog.163.com 作者:dl-lzx
顶一下
(0)
0%
踩一下
(1)
100%
------分隔线----------------------------
相关文章
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容