Use a Mutex, so that CPL applets cannot be launched multiple times.
authorColin Finck <colin@reactos.org>
Tue, 13 May 2008 08:56:23 +0000 (08:56 +0000)
committerColin Finck <colin@reactos.org>
Tue, 13 May 2008 08:56:23 +0000 (08:56 +0000)
Fixes bug #781 partly, we still need a fix in "control.exe" (see my comment in the bug report)

svn path=/trunk/; revision=33492

reactos/dll/win32/shell32/control.c

index b495f86..293259a 100644 (file)
@@ -353,7 +353,11 @@ static     void    Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
     LPWSTR     extraPmts = NULL;
     int        quoted = 0;
     BOOL       spSet = FALSE;
+       HANDLE hMutex;
 
+    hMutex = CreateMutex(NULL, FALSE, (LPCTSTR) wszCmd);
+       if ((!hMutex) || (GetLastError() == ERROR_ALREADY_EXISTS))
+        return NULL;
     buffer = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(wszCmd) + 1) * sizeof(*wszCmd));
     if (!buffer) return;
 
@@ -412,6 +416,7 @@ static      void    Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
        }
        Control_UnloadApplet(applet);
     }
+       ReleaseMutex(hMutex);
     HeapFree(GetProcessHeap(), 0, buffer);
 }