WinCE怎么判断进程是否已经存在???
时间:2011-12-08
来源:互联网
在网上找到这端代码
C# code
我按照这个做的,我的工程名字是AProject,可是检测时候时候即使我已经开启了这个软件,再次开启时还是检测不到开启,请问CreateMutex(null, false, processName);中得软件名字该写什么呢?
C# code
using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace WindowsApplication1 { /// <summary> /// MobileUtils /// </summary> public class MobileUtils { /// <summary> /// 判断某个进程是否已经存在 /// </summary> /// <param name="name"></param> /// <returns></returns> public static bool IsProcessRunning(string processName) { int hMutex; hMutex = CreateMutex(null, false, processName); if (GetLastError() == ERROR_ALREADY_EXISTS) { ReleaseMutex(hMutex); return true; } return false; } /// <summary> /// GetLastError /// </summary> /// <returns></returns> [DllImport("coredll.Dll")] private static extern int GetLastError(); /// <summary> /// ReleaseMutex /// </summary> /// <param name="hMutex"></param> /// <returns></returns> [DllImport("coredll.Dll")] private static extern int ReleaseMutex(int hMutex); /// <summary> /// CreateMutex /// </summary> /// <param name="lpMutexAttributes"></param> /// <param name="bInitialOwner"></param> /// <param name="lpName"></param> /// <returns></returns> [DllImport("coredll.Dll")] private static extern int CreateMutex(SECURITY_ATTRIBUTES lpMutexAttributes, bool bInitialOwner, string lpName); /// <summary> /// /// </summary> private const int ERROR_ALREADY_EXISTS = 0183; /// <summary> /// SECURITY_ATTRIBUTES /// </summary> [StructLayout(LayoutKind.Sequential)] private class SECURITY_ATTRIBUTES { /// <summary> /// /// </summary> public int nLength; /// <summary> /// /// </summary> public int lpSecurityDescriptor; /// <summary> /// /// </summary> public int bInheritHandle; } } }
我按照这个做的,我的工程名字是AProject,可是检测时候时候即使我已经开启了这个软件,再次开启时还是检测不到开启,请问CreateMutex(null, false, processName);中得软件名字该写什么呢?
作者: nkhuangyanping 发布时间: 2011-12-08
估计我这个不支持,大家知道有什么别的办法吗?
作者: nkhuangyanping 发布时间: 2011-12-08
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28