让程序只运行一个实例的方法
2011-03-20 16:25
344 查看
//首先在InitInstance()函数中创建一个同步对象,如果(GetLastError()返回ERROR_ALREADY_EXISTS就表明存在
//一个应用实例了,返回false取消
// 创建同步对象
//首先在InitInstance()函数中创建一个同步对象,如果(GetLastError()返回ERROR_ALREADY_EXISTS就表明存在
//一个应用实例了,返回false取消
// 创建同步对象
//一个应用实例了,返回false取消
// 创建同步对象
//By cryfish hMutexOneInstantance=CreateMutex(NULL,TRUE,_T("PreventSecondInstance")); if(GetLastError()==ERROR_ALREADY_EXISTS) bFound=TRUE; if(hMutexOneInstantance) ReleaseMutex(hMutexOneInstantance); if (bFound==TRUE) { ::AfxMessageBox("You have Run one"); return false; } |
//一个应用实例了,返回false取消
// 创建同步对象
//By cryfish hMutexOneInstantance=CreateMutex(NULL,TRUE,_T("PreventSecondInstance")); if(GetLastError()==ERROR_ALREADY_EXISTS) bFound=TRUE; if(hMutexOneInstantance) ReleaseMutex(hMutexOneInstantance); if (bFound==TRUE) { ::AfxMessageBox("You have Run one"); return false; } |
相关文章推荐
- 解决C#程序只允许运行一个实例的几种方法详解
- 只能运行一个程序实例的两种方法对比
- 让程序只运行一个实例的方法总结
- 转:一个程序只运行一个实例的最有效方法. 收藏
- 让程序只运行一个实例的方法
- 让程序只运行一个实例的方法
- 在VC++中实现让程序只运行一个实例的方法
- 让程序只运行一个实例的5种方法
- [转]让程序只运行一个实例的四种方法
- C#只能运行一个实例程序的方法
- 让程序只运行一个实例的四种方法
- 程序只能运行一个实例方法
- 转:让程序只运行一个实例的四种方法
- C#只能运行一个实例程序的方法
- 让程序只运行一个实例的四种方法
- 利用互斥对象实现一个程序只运行一个实例的方法.
- 【转】delphi程序只允许运行一个实例的三种方法:
- 程序只运行一个实例方法
- 让程序只运行一个实例的方法
- 让Java程序只运行一个实例(两种方法都好用)