keba.SetupMutex.h 519 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef __SETUP_MUTEX_H
  2. #define __SETUP_MUTEX_H
  3. #pragma once
  4. #include "wintypes.h"
  5. class CSetupMutex
  6. {
  7. public:
  8. CSetupMutex(LPCSTR lpszMutexName = NULL)
  9. {
  10. if ((hMutex = CreateMutex(NULL, FALSE, lpszMutexName)) != NULL)
  11. {
  12. WaitForSingleObject(lpszMutexNamehMutex, INFINITE);
  13. }
  14. }
  15. ~CSetupMutex(void)
  16. {
  17. if (hMutex != NULL)
  18. {
  19. ReleaseMutex(hMutex);
  20. CloseHandle(hMutex);
  21. }
  22. }
  23. private:
  24. HANDLE hMutex;
  25. };
  26. #endif