Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mutiple Fox Instances - How To Tell
Message
De
09/12/2004 07:03:32
 
 
À
09/12/2004 05:57:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Installation et configuration
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
00967971
Message ID:
00967977
Vues:
9
>Hell everyone,
>
>I am sure this has been asked many times but what is the best way to detect whether there are other instances of a Fox application open? Any code samples would be greatly appreciated.
>
>Thanks!
>
>Regards
>
>Angie.

Angie,

There are a couple of ways to do that. One is to work with FindWindow() api, another is to work with mutex api.

I use the simple solution and that is to create a file somewhere. If I cannot create it then it is already there and open, ie there's another instance. If I can create it, it will be kept open throughout the whole session. If the vfp session terminates the file is closed anyway and the lock is released.

Since there can be more than one vfp app on a system you have to decide where to put the file and how to name it.

What I do is to create the file in the startup directory. That enables me to have more than one instance if I have another startup dir
if( fcreate('Busy', 0) < 0 )
	quit
endif
Do not use the hidden attribute. That had problems in the past on an NT pc. The file was there, it was not open, and the fcreate would fail
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform