#include "stdafx.h"
#include "windows.h"
int _tmain(int argc, _TCHAR* argv[])
{
CRITICAL_SECTION CriticalSection;
// Initialize the critical section.
InitializeCriticalSection(&CriticalSection);  // Request ownership of the critical section.
__try 
{
EnterCriticalSection(&CriticalSection);  // Access the shared resource.
}
__finally 
{
// Release ownership of the critical section.
LeaveCriticalSection(&CriticalSection); // Release resources used by the critical section object.
DeleteCriticalSection(&CriticalSection);
}
return 0;
}