All pastes #974353 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-06 19:06 UTC
rendered paste body
#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;
}