The best way to test this sample is to create a project with the code below and compile it in an executable file. Though whichever way you choose: an executable, an application, or another VFP instance -- this code works fine.
A combination of two functions -- Create... and Open... -- is used, and it is not the only Semaphore object good for this task.
Same can be done with Mutex object (MutuallyExclusive), or Event object. First you try to open the named object. If it already exists, that means another VFP application instance is running. Otherwise you create the object within this instance.