>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