| 1838 | InstanceMutex g_instanceMutex; |
| 1839 | |
| 1840 | static bool ForceSingleInstance(LPCTSTR pClassName) |
| 1841 | { |
| 1842 | HRESULT hResult = g_instanceMutex.Init(); |
| 1843 | |
| 1844 | if (hResult != ERROR_ALREADY_EXISTS) |
| 1845 | return true; |
| 1846 | |
| 1847 | HWND hWnd = FindWindow(pClassName, NULL); |
| 1848 | if (hWnd) |
| 1849 | { |
| 1850 | DWORD_PTR dwResult = 0; // ignored |
| 1851 | if (SendMessageTimeout(hWnd, WM_RESTOREAPP, 0, 0, SMTO_BLOCK | SMTO_ABORTIFHUNG | SMTO_ERRORONEXIT, 3000, &dwResult)) |
| 1852 | // The message was received by the app to restore its window. |
| 1853 | return false; |
| 1854 | |
| 1855 | // Ok, so we probably have a hung process. |
| 1856 | // Instruct them to close or terminate the hung process. |
| 1857 | MessageBox(NULL, TmGetTString(IDS_TERMINATE_HUNG_PROCESS), TmGetTString(IDS_PROGRAM_NAME), MB_ICONWARNING | MB_OK); |
| 1858 | return false; |
| 1859 | } |
| 1860 | return false; |
| 1861 | } |
| 1862 | |
| 1863 | #include "MemberListOld.hpp" |
| 1864 | |