| 29 | } |
| 30 | |
| 31 | bool DesktopLock::tryLock() |
| 32 | { |
| 33 | if (isLocked()) |
| 34 | return true; |
| 35 | |
| 36 | lockFileHandle = CreateFile((LPCTSTR) native(QFileInfo(winOS->GetUserLocalApplicationDataPath(), QString(lockFileName))).utf16(), |
| 37 | GENERIC_READ | GENERIC_WRITE, |
| 38 | 0, // don't share the file, this locks it |
| 39 | NULL, |
| 40 | OPEN_ALWAYS, // create the file if it doesn't exist |
| 41 | FILE_ATTRIBUTE_NORMAL, |
| 42 | NULL); |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | return isLocked(); |
| 48 | } |
| 49 | void DesktopLock::unlock() |
| 50 | { |
| 51 | if (lockFileHandle != INVALID_HANDLE_VALUE) |