展开全部
wince莫非没有获取进程的函数?记得是有的,看看开发文档吧,一般是通过进程名称来确定的
追问
不是啦。去csdn上看了好多判断当前程序是否已经打开的方法都不行。
Process.GetProcesses() 没有这个方法,好吧。process类有的~
Mutex mut=new Mutex(false, ProcessName, createdNew);没有这个重载,好吧。Mutex类有的~
.Process.GetProcessesByName 没有这个方法~
追答
方法还是很多的嘛:
1 using System;
2 using System.Runtime.InteropServices;
3
4 class Mutex
5 {
6 [DllImport("coredll.Dll")]
7 private static extern int GetLastError();
8
9 [DllImport("coredll.Dll")]
10 private static extern int ReleaseMutex(IntPtr hMutex);
11
12 [DllImport("coredll.Dll")]
13 private static extern IntPtr CreateMutex(
14 SECURITY_ATTRIBUTES lpMutexAttributes,
15 bool bInitialOwner, string lpName);
16
17 [StructLayout(LayoutKind.Sequential)]
18 public class SECURITY_ATTRIBUTES
19 {
20 public int nLength;
21 public int lpSecurityDescriptor;
22 public int bInheritHandle;
23 }
24
25 private const int ERROR_ALREADY_EXISTS = 0183;
26
27 public static void Run()
28 {
29 IntPtr hMutex = CreateMutex(null, false, "ZJS_FJ");
30 if (GetLastError() != ERROR_ALREADY_EXISTS)
31 {
32 System.Windows.Forms.Application.Run(new Form1());
33 return;
34 }
35 else
36 {
37 ReleaseMutex(hMutex);
38 return;
39 }
40 }
41 }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询