Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I avoid to multiple run of VFP application on one PC
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
How can I avoid to multiple run of VFP application on one PC
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01017848
Message ID:
01017848
Vues:
85
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.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform