Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to check if an application is already running ?
Message
De
01/04/2004 08:18:40
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
01/04/2004 08:04:29
Arlei Silva
Chevron Oronite Brasil Ltda.
Capuava, Brésil
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00891439
Message ID:
00891447
Vues:
30
This message has been marked as the solution to the initial question of the thread.
>Hi all,
>
>I have to check if an application is already running, so I cannot allow the user to fire up other instances...
>
>However, the running application may have its main form hided and an icon in the system tray. In this case, the API function FindWindow() does not work :(
>
>I think I will have to work with some sort of "process" functions, but I am lost here... Could you please shed some light ?
>
>Thanks,
If AppAlreadyRunning()
  Messagebox('Another instance is already running.')
...

Function AppAlreadyRunning
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
lpszSemName = "AnyStringUniqueToYourApp"
hsem = CreateSemaphore(0,0,1,lpszSemName)
Return (hsem # 0 And GetLastError() == ERROR_ALREADY_EXISTS)
PS:FindWindow() works with ClassNames too.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform