[ros-diffs] [pschweitzer] 56160: [KBSWITCH] Properly use the single instance mutex

pschweitzer at svn.reactos.org pschweitzer at svn.reactos.org
Thu Mar 15 20:56:26 UTC 2012


Author: pschweitzer
Date: Thu Mar 15 20:56:26 2012
New Revision: 56160

URL: http://svn.reactos.org/svn/reactos?rev=56160&view=rev
Log:
[KBSWITCH]
Properly use the single instance mutex

Modified:
    trunk/reactos/base/applications/kbswitch/kbswitch.c

Modified: trunk/reactos/base/applications/kbswitch/kbswitch.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch/kbswitch.c?rev=56160&r1=56159&r2=56160&view=diff
==============================================================================
--- trunk/reactos/base/applications/kbswitch/kbswitch.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/kbswitch.c [iso-8859-1] Thu Mar 15 20:56:26 2012
@@ -519,8 +519,14 @@
     HANDLE hMutex;
 
     hMutex = CreateMutex(NULL, FALSE, szKbSwitcherName);
-    if ((!hMutex) || (GetLastError() == ERROR_ALREADY_EXISTS))
+    if (!hMutex)
         return 1;
+
+    if (GetLastError() == ERROR_ALREADY_EXISTS)
+    {
+        CloseHandle(hMutex);
+        return 1;
+    }
 
     hInst = hInstance;
     hProcessHeap = GetProcessHeap();
@@ -537,7 +543,10 @@
     WndClass.lpszClassName = szKbSwitcherName;
 
     if (!RegisterClass(&WndClass))
+    {
+        CloseHandle(hMutex);
         return 1;
+    }
 
     CreateWindow(szKbSwitcherName, NULL, 0, 0, 0, 1, 1, HWND_DESKTOP, NULL, hInstance, NULL);
 
@@ -547,7 +556,7 @@
         DispatchMessage(&msg);
     }
 
-    if (hMutex) CloseHandle(hMutex);
+    CloseHandle(hMutex);
 
     return 0;
 }




More information about the Ros-diffs mailing list