123456789101112131415161718192021222324252627282930 |
- #pragma once
- #include "resource.h"
- #include "..\..\Module\mod_FreeRDPWrap\PipeCommon.h"
- namespace SpDeskShareNS {
- class CDuplicateCheck {
- public:
- CDuplicateCheck():hMutex(NULL) {}
- ~CDuplicateCheck() {if(hMutex != NULL) {CloseHandle(hMutex); hMutex = NULL;}}
- BOOL IsDuplicated() {
- static int onlyOnce = -1;
- if(onlyOnce == -1) {
- hMutex = CreateMutex(NULL, true, "{00F2E171-F8E9-40CD-86D1-5FDC45599B02}");
- if(hMutex && GetLastError() == ERROR_ALREADY_EXISTS) {
- onlyOnce = 1;
- return TRUE;
- }
- onlyOnce = 0;
- return FALSE;
- }
- return onlyOnce == 0 ? FALSE : TRUE;
- }
- private:
- HANDLE hMutex;
- };
- }
|