Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Preventing Multiple Launches
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00296974
Message ID:
00298610
Vues:
19
>>>The mutex is the most complex, but also the most reliable in terms of making the determination. Unfortunately, if the code to release the mutex (which is in shutdown) doesn't execute, the mutex isn't released. This can happen if VFP generates a 0xC0000005 error (GPFs). Further, this can and does happen if VFP 6.0 without SP3 and DCOM95 (under Win95) isn't installed with top-level type application (_SCREEN.Visible = .F.).
>>>
>>>hth,
>>
>>A mutex can be created without an owner:
>
>This is correct.
>
>>Each process get a Handle to the mutex, that the system close when the process terminate or by CloseHandle(), so there is no need to call ReleaseHandle by Any instance of the application.
>
>If, however, the mutex isn't released (via WaitForSingleObject(), ReleaseMutex(), and CloseHandle()) when an application shuts down, any subsequent attempts to to run the application will fail if the mutex is un-owned, unless the system is re-started.

MSDN Documentation on CreateMutex:

"The system closes the handle automatically when the process terminates. The mutex object is destroyed when its last handle has been closed."

For a simple test build a executable of the following code. Only the first instance will show the message: 'Application sucessfully running'. But if you exit every instance of the application, and run again, you will see the same message. There is not explicit call to CloseHandle(), the system release the mutex when all the instance of the application are closed.
*-- Code Start
#define ERROR_ALREADY_EXISTS 183

Declare Integer CreateMutex in win32api integer, integer, string
Declare Integer GetLastError in win32api 

CreateMutex(0, 0, 'MutexTest');

if GetLastError() = ERROR_ALREADY_EXISTS
    MessageBox('Application ALREADY running', 0, 'TestMutex')
else
    MessageBox('Application SUCESSFULLY running', 0, 'TestMutex')
endif

Return

Just an opinion... Not a fact.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform