65,187
社区成员




if (!oneinstance())
{
return TRUE;
}
试一下 HANDLE hMutex;
hMutex = CreateMutex(NULL, FALSE, "YourProgramName" );
if ( WaitForSingleObject(hMutex, 1000) == WAIT_TIMEOUT ) {
// There is another instance out there, but it is taking to long to
// locate, just exit
return FALSE;
}
if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
ReleaseMutex(hMutex);
return FALSE;
}
……
ReleaseMutex(hMutex);
CloseHandle(hMutex);