×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Microsoft: FoxPro FAQ

FoxPro Enviroment

How to run only one instance for FoxPro DOS application by ramani
Posted: 8 Nov 02

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.

Simple trick. Isn't It?
**********************************************************
** Ramani  (Subramanian.G), FoxAcc, ramani_g@yahoo.com
** EOF
**********************************************************

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close