Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: mutex.h
  4. //
  5. // Module: CMSETUP.LIB, CMDIAL32.DLL, CMDL32.EXE
  6. //
  7. // Synopsis: Definition of the class CNamedMutex
  8. //
  9. // Copyright (c) 1998-1999 Microsoft Corporation
  10. //
  11. // Author: fengsun Created 02/26/98
  12. //
  13. //+----------------------------------------------------------------------------
  14. #ifndef __CM_MUTEXT_H
  15. #define __CM_MUTEXT_H
  16. #include <windows.h>
  17. #include "cmdebug.h"
  18. //+---------------------------------------------------------------------------
  19. //
  20. // class CNamedMutex
  21. //
  22. // Description: A class to lock/unlock a named mutex
  23. // The destructor releases the mutex.
  24. //
  25. // History: fengsun Created 2/19/98
  26. //
  27. //----------------------------------------------------------------------------
  28. class CNamedMutex
  29. {
  30. public:
  31. CNamedMutex() {m_hMutex = NULL; m_fOwn = FALSE;}
  32. ~CNamedMutex() {Unlock();}
  33. BOOL Lock(LPCTSTR lpName, BOOL fWait = FALSE, DWORD dwMilliseconds = INFINITE, BOOL fNoAbandon = FALSE);
  34. void Unlock();
  35. protected:
  36. HANDLE m_hMutex; // the handle of the mutex
  37. BOOL m_fOwn; // whther we own the mutex
  38. };
  39. #endif //__CM_MUTEXT_H