Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- #include<Windows.h>
- HANDLE semaphore;
- #define NAME "Local\\SemaphoreName"
- int main() {
- semaphore = OpenSemaphore(NULL, TRUE, NAME);
- if (semaphore == NULL) {
- semaphore = CreateSemaphore(NULL, 3, 3, NAME);
- }
- if (semaphore == NULL)
- return EXIT_FAILURE;
- WaitForSingleObject(semaphore, INFINITE);
- printf("Window Opened\n\n");
- system("pause");
- ReleaseSemaphore(semaphore , 1 , NULL);
- CloseHandle(semaphore);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement