Anonymous
public text v1 · immutable#include <windows.h>
#include <stdio.h>
BOOL CreateInstance(LPCTSTR lpszApplicationName)
{
return (CreateMutex(NULL, TRUE, lpszApplicationName) == NULL) ? ((GetLastError() == ERROR_ALREADY_EXISTS) ? FALSE : TRUE) : TRUE;
}
int main(){
if(CreateInstance("spawnMs"))
printf("No other instance running");
else{
printf("Instance running");
}
Sleep(3000);
return 0;
}