#include <stdio.h>
#include <tchar.h>
#include <windows.h>
BOOL isAlreadyRunning()
{
HANDLE handle = CreateMutex(NULL, TRUE, _T("TESTTEST"));
DWORD dwCode = GetLastError();
if (handle == NULL || dwCode == ERROR_ALREADY_EXISTS)
{
return TRUE;
}
return FALSE;
}
int main()
{
if( isAlreadyRunning() )
{
printf("程序已经在运行.\n");
return -1;
}
while(1)
{
}
return 0;
}