首页 > 编程语言 >让程序只运行一个实例的简单实用的方法

让程序只运行一个实例的简单实用的方法

时间:2023-01-24 14:05:02浏览次数:42  
标签:bFound GetLastError 程序 实用 实例 TRUE 运行 hMutexOneInstantance

//
//只能运行一个实例
HANDLE hMutexOneInstantance=CreateMutex(NULL,TRUE,_T("PreventSecondInstance"));
BOOL bFound=FALSE;
if(GetLastError()==ERROR_ALREADY_EXISTS)
bFound=TRUE;
if(hMutexOneInstantance)
ReleaseMutex(hMutexOneInstantance);
if (bFound==TRUE)
{
//::AfxMessageBox("您已经运行了一个实例");
return false;
}

标签:bFound,GetLastError,程序,实用,实例,TRUE,运行,hMutexOneInstantance
From: https://blog.51cto.com/u_15942605/6022284

相关文章