| 126 | |
| 127 | |
| 128 | bool ShutdownCheckAnother(bool Open) |
| 129 | { |
| 130 | const wchar *EventName=L"rar -ioff"; |
| 131 | static HANDLE hEvent=NULL; |
| 132 | bool Result=false; // Return false if no other RAR -ioff are running. |
| 133 | if (Open) // Create or open the event. |
| 134 | hEvent=CreateEvent(NULL,FALSE,FALSE,EventName); |
| 135 | else |
| 136 | { |
| 137 | if (hEvent!=NULL) |
| 138 | CloseHandle(hEvent); // Close our event. |
| 139 | // Check if other copies still own the event. While race conditions |
| 140 | // are possible, they are improbable and their harm is minimal. |
| 141 | hEvent=CreateEvent(NULL,FALSE,FALSE,EventName); |
| 142 | Result=GetLastError()==ERROR_ALREADY_EXISTS; |
| 143 | if (hEvent!=NULL) |
| 144 | CloseHandle(hEvent); |
| 145 | } |
| 146 | return Result; |
| 147 | } |
| 148 | #endif |
| 149 | |
| 150 | |