The follwing will ensure that you run your application only once in your computer.
Step:1 .. In your main.prg which starts you application.. add the following as your first 5 lines.
**********************************************************
DEFINE WINDOW myApp FROM 1,1 to 5,5 NONE
ON ERROR DO myExit
MODI COMM C:\myAppl.txt WINDOW myApp NOWAIT
HIDE WINDOW myApp BOTTOM
ON ERROR && as you will follow your own ON ERROR routines
*********************************************************
Step:2 .. Then at the end of your same PRG, add the following.
*********************************************************
PROCEDURE myExit
WAIT WINDOW "Application is already running"
QUIT
*********************************************************
Step:3 .. Now create a text file "myAPp.txt" in the clients c:drive and save it. There is a need for only a single space in that file.. to avoid display of the content in the application screen.
Once the file is there, the application will open the file in read-write mode and lock it by itself. Next attempt cannot open that and so the error condition will logout the user. Even if the application, is multiuser and is in Server, the opening of myApp.txt in C drive will ensure that each usr starts only once.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.