Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One Instance
Message
De
26/11/2004 10:08:53
 
 
À
04/11/2004 09:40:14
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
00957965
Message ID:
00964914
Vues:
11
>>Hi All,
>>
>>How would I write code(s) to allow only one instance of the application to be executed? (check and prevent execution) Any suggestions or ideas is very appreciated.
>>
>>TIA
>
>
>* Entr
>if IsAppRunning(Application.ServerName) && or any unique string you want - ie: MyNiceApplication
>*...
>endif
>
>Function IsAppRunning
>	Lparameters tcSemaphoreName
>	Local hsem, lpszSemName
>	#Define ERROR_ALREADY_EXISTS 183
>	Declare Integer GetLastError In win32API
>	Declare Integer CreateSemaphore In WIN32API ;
>		string @ lpSemaphoreAttributes, ;
>		LONG lInitialCount, ;
>		LONG lMaximumCount, ;
>		string @ lpName
>	hsem = CreateSemaphore(0,0,1,tcSemaphoreName)
>	Return (hsem # 0 And GetLastError() == ERROR_ALREADY_EXISTS)
>
Cetin

Hi Cetin,
you have found a code that with the semaphore, active the application that has created it?
IF hsem # 0 And GetLastError() == ERROR_ALREADY_EXISTS
   * samaphore => ProcessId => WHANDLE => SetForegroundWindow(WHANDLE)
ENDIF
I wan't use FindWindow because it is mistaken.

Thanks
Fabio
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform