SpDeskShare.h 641 B

123456789101112131415161718192021222324252627282930
  1. #pragma once
  2. #include "resource.h"
  3. #include "..\..\Module\mod_FreeRDPWrap\PipeCommon.h"
  4. namespace SpDeskShareNS {
  5. class CDuplicateCheck {
  6. public:
  7. CDuplicateCheck():hMutex(NULL) {}
  8. ~CDuplicateCheck() {if(hMutex != NULL) {CloseHandle(hMutex); hMutex = NULL;}}
  9. BOOL IsDuplicated() {
  10. static int onlyOnce = -1;
  11. if(onlyOnce == -1) {
  12. hMutex = CreateMutex(NULL, true, "{00F2E171-F8E9-40CD-86D1-5FDC45599B02}");
  13. if(hMutex && GetLastError() == ERROR_ALREADY_EXISTS) {
  14. onlyOnce = 1;
  15. return TRUE;
  16. }
  17. onlyOnce = 0;
  18. return FALSE;
  19. }
  20. return onlyOnce == 0 ? FALSE : TRUE;
  21. }
  22. private:
  23. HANDLE hMutex;
  24. };
  25. }