Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Semaphore_test.cpp : Defines the entry point for the console application.
- //
- #include <stdio.h>
- #include <Windows.h>
- #include <fcntl.h>
- HANDLE semaphore;
- DWORD Limit = 5;
- DWORD timeout = 0;
- DWORD res = 0;
- int main()
- {
- semaphore = OpenSemaphore(SEMAPHORE_ALL_ACCESS, false, (LPCWSTR)"sem");
- if (semaphore == NULL){
- semaphore = CreateSemaphore(NULL, 3, Limit, (LPCWSTR)"sem");
- }
- res = WaitForSingleObject(semaphore, timeout);
- printf("res: %i", &res);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement