1.1 --- a/GateKeeper.cpp Sat Nov 12 21:52:41 2016 +0100
1.2 +++ b/GateKeeper.cpp Sun Nov 13 08:13:54 2016 +0100
1.3 @@ -380,15 +380,23 @@
1.4 void GateKeeper::update_product(product p, DWORD context)
1.5 {
1.6 {
1.7 - HANDLE hSemaphore = CreateSemaphore(NULL, 0, 2, _T("PEPINSTALLERSEMAPHORE"));
1.8 - DWORD le = GetLastError();
1.9 - if (hSemaphore) {
1.10 - CloseHandle(hSemaphore);
1.11 - if (le == ERROR_ALREADY_EXISTS)
1.12 - return;
1.13 + const tstring _fileName = _T("\\pEpSetup.lck");
1.14 +
1.15 + unique_ptr < TCHAR[] > _pathName(new TCHAR[MAX_PATH + 1]);
1.16 + DWORD size = GetTempPath(MAX_PATH, _pathName.get());
1.17 + if (size > MAX_PATH - _fileName.size())
1.18 + throw runtime_error("TEMP path too long");
1.19 +
1.20 + tstring fileName(_pathName.get());
1.21 + fileName += _fileName;
1.22 +
1.23 + HANDLE file = CreateFile(fileName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
1.24 + if (file == INVALID_HANDLE_VALUE) {
1.25 + return;
1.26 }
1.27 else {
1.28 - return;
1.29 + CloseHandle(file);
1.30 + DeleteFile(fileName.c_str());
1.31 }
1.32 }
1.33