VirtualBox

Ignore:
Timestamp:
May 16, 2008 2:06:46 PM (17 years ago)
Author:
vboxsync
Message:

Windows Guest VBoxTray: Implemented single instance checking (global mutex).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp

    r8887 r8897  
    535535int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    536536{
    537     dprintf(("VBoxService: WinMain\n"));
     537    /* Do not use a global namespace ("Global\\") for mutex name here, will blow up NT4 compatibility! */
     538    HANDLE hMutexAppRunning = CreateMutex (NULL, FALSE, "VBoxTray");
     539    if (   (hMutexAppRunning != NULL)
     540        && (GetLastError() == ERROR_ALREADY_EXISTS))
     541   {
     542      /* Close the mutex for this application instance. */
     543      CloseHandle (hMutexAppRunning);
     544      hMutexAppRunning = NULL;
     545      return 0;
     546   }
     547
     548    dprintf(("VBoxService: Started.\n"));
     549
    538550    gInstance = hInstance;
    539551    VBoxServiceStart();
    540    
     552
     553    dprintf(("VBoxService: Ended.\n"));
     554
     555    /* Release instance mutex. */
     556    if (hMutexAppRunning != NULL) {
     557        CloseHandle (hMutexAppRunning);
     558        hMutexAppRunning = NULL;
     559    }
     560
    541561    return 0;
    542562}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette