WINCE中只允许程序运行一个实例
时间:2011-02-25 来源:narcissus
static void Main() { #region Api_Call CreateMutex; IntPtr hMutex; hMutex=CreateMutex(null,false,"程序名"); if (GetLastError()!=ERROR_ALREADY_EXISTS) { Application.Run(new Frmmenu()); } else { MessageBox.Show("本程序只允许同时运行一个"); ReleaseMutex(hMutex); } #endregion }
EVC:
HANDLE hMutex=::CreateMutex(NULL,TRUE,L"LiCR"); if(hMutex!=NULL) { if(GetLastError()==ERROR_ALREADY_EXISTS) {
AfxMessageBox( "已经有一个程序运行." );
ReleaseMutex(hMutex);
return FALSE;
}
}
相关阅读 更多 +