創建信號燈, 一種內核對象的同步方式
使用步驟如下
1,創建信號燈
HANDLE hCounter = CreateSemaphore(NULL,2,2,"iCounter")
2,打開信號燈
hCounterIn=OpenSemaphore(SEMAPHORE_ALL_ACCESS,FALSE,"iCounter")
3,等待信號燈WaitForSingleObject(hCounterIn,INFINITE);
4,釋放信號燈ReleaseSemaphore(hCounterIn,1,NULL);
4, 關閉句柄了CloseHandle(hCounter)