Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I avoid to multiple run of VFP application on on
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01017848
Message ID:
01017894
Vues:
26
For a detailed discussion regarding this subject and a number of examples on how to implement this into your VFP applicaiton you can look at:

http://www.tek-tips.com/viewthread.cfm?qid=672388

...mutexes, semaphores, unique window properties, global atom table, DDE, and other approaches are all covered, including some of the pros and cons of each.

>Could somebody tell me the way to avoid multiple running of one VFP application on
>one machine at the same time. I have some tip to use CreateMutex(...), but it seems
>doesn't work:
>
>
>*!* APPClass.Init
>LPARAMETERS pScreenTitle, pMutex
>#DEFINE ERROR_ALREADY_EXISTS 255
>DECLARE INTEGER CreateMutex	        IN win32api INTEGER, INTEGER, STRING @
>DECLARE INTEGER CloseHandle	        IN win32api INTEGER
>DECLARE INTEGER GetLastError        IN win32api
>DECLARE INTEGER FindWindow          IN Win32api STRING, STRING
>DECLARE INTEGER IsIconic            IN Win32api INTEGER
>DECLARE         ShowWindow          IN Win32api INTEGER, INTEGER
>DECLARE         SetForegroundWindow IN Win32api INTEGER
>
>LOCAL lMutex, nWinHandle,lnError
>lMutex = IIF(pcount()<2, pScreenTitle, pMutex)
>THIS.nExeHwnd = CreateMutex(0, 1, @lMutex)
>lnError=GetLastError()
>IF lnError = ERROR_ALREADY_EXISTS
>	CloseHandle(THIS.nExeHwnd)
>	MESSAGEBOX("ERROR"+CHR(13)+"This application is allready running."+CHR(13)+ "Shut down...", ;
>		MB_OK+MB_ICONSTOP, pScreenTitle)
>		MB_OK+MB_ICONSTOP, pScreenTitle)
>	nWinHandle = FindWindow(NULL, pScreenTitle)
>	IF nWinHandle # 0
>		IF IsIconic(nWinHandle) = 1
>			ShowWindow(nWinHandle,4)
>		ENDIF
>		SetForegroundWindow(nWinHandle)
>	ENDIF
>	RETURN .F.
>ENDIF
>
>
>Thanks for your reactions.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform