随手写
#include <iostream>
#include <windows.h>
using namespace std;
void main()
{
cout<<"OK"<<endl;
while(TRUE)
{
HANDLE hMutex = ::CreateMutex(NULL, FALSE, "Mutex");
WaitForSingleObject(hMutex, INFINITE);
cout<<"in"<<endl;
Sleep(2000);
cout<<"out"<<endl;
ReleaseMutex(hMutex);
}
}