/scilab-master-1333395999/modules/windows_tools/src/c/scilab_windows/InnosetupMutex.c

# · C · 45 lines · 23 code · 1 blank · 21 comment · 1 complexity · b7bef746b3becf4e27ec0ae0b1207c6a MD5 · raw file

  1. /*
  2. * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  3. * Copyright (C) INRIA - 2008 - Allan CORNET
  4. * Copyright (C) DIGITEO - 2012 - Allan CORNET
  5. *
  6. * This file must be used under the terms of the CeCILL.
  7. * This source file is licensed as described in the file COPYING, which
  8. * you should have received as part of this distribution. The terms
  9. * are also available at
  10. * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  11. *
  12. */
  13. /*--------------------------------------------------------------------------*/
  14. #include <windows.h>
  15. #include "InnosetupMutex.h"
  16. #include "BOOL.h"
  17. #include "version.h"
  18. /*--------------------------------------------------------------------------*/
  19. static HANDLE hMutexScilabID;
  20. /*--------------------------------------------------------------------------*/
  21. void createInnosetupMutex(void)
  22. {
  23. /* http://www.vincenzo.net/isxkb/index.php?title=Application_considerations */
  24. /* creates a named mutex used by Innosetup */
  25. hMutexScilabID = CreateMutex (NULL, FALSE,SCI_VERSION_STRING );
  26. }
  27. /*--------------------------------------------------------------------------*/
  28. void closeInnosetupMutex(void)
  29. {
  30. /* close named mutex */
  31. CloseHandle(hMutexScilabID);
  32. }
  33. /*--------------------------------------------------------------------------*/
  34. BOOL haveInnosetupMutex(void)
  35. {
  36. HANDLE hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, SCI_VERSION_STRING);
  37. if (hMutex)
  38. {
  39. CloseHandle(hMutex);
  40. return TRUE;
  41. }
  42. return FALSE;
  43. }
  44. /*--------------------------------------------------------------------------*/