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

Microsoft: FoxPro FAQ

Tips -N- Tricks

A way to force Users out of your VFP application. by ramani
Posted: 10 Feb 03

** Author : Ramani (Subramanian.G)
**          FoxAcc Software / Winners Software
**          ramani_g@yahoo.com
** Type   : Copyrights reserved except for personal use
** Warranty : Nothing implied or explicit
** Last modified : 10 February, 2003
1. In your Main.PRG ..
   Before the main event is started..
   Add code...
   PUBLIC pnShutSeconds, ptShutTime
   pnShutSeconds = 0
   ptShutTime = {}
   ** To avoid new users from starting application **
   IF FILE("DoShut.txt")
      =MESSAGEBOX("Try after some time",0+16+ ;
               "System maintenance in progress")

2. Add a timer class to your application.
   In the Timer event of the Timer class.. add the code..
IF m.pnShutSeconds = 0
  IF FILE("DoShut.txt")
     m.pnShutSeconds = VAL(FILETOSTR("DoShut.txt"))
     m.ptShutTime = DATETIME()+VAL(FILETOSTR("DoShut.txt"))
IF m.pnShutSeconds > 0
   WAIT WINDOW "Maintenance shutdown called by " + ;
     "System Administrator" + CHR(13)+ ;
     "Please Close down your application before " + ;
     "the forced shutdown."+ CHR(13)+ CHR(13)+;
     "ShutDown Time "+TTOC(m.ptShutTime) + CHR(13)+ ;
     "Current Time is "+TTOC(DATETIME()) NOWAIT NOCLEAR
   IF DATETIME() > m.ptShutTime
      ** Instead of ThisForm.Release,
      ** you may have to call a shutdown routine.

3. Set the timer interval as 1000 (1 second) or even (10000=10 seconds) so that the resources are not drained by the timer call.

4. Drop this timer class in your base application form
   or drop it in all forms of your application.

5. Steps you have to take.. to make this call..
   a. When you need to make a shutdown call..
   b. Start VFP.. change to the default application
      directory in the server place..
   c. Decide the shutdown time you want to allow
      This shall be in seconds.. say 300 for 5 minutes
   d. In the command window..
      [Note: Avoid opening a text file with the name
      DoShut.txt using command as MODI FILE DoShut.txt
      since that will open a file with a lock and
      create an error in the Timer event of application.
      So either copy a file or do as above to make an
      instatneous DoShut.txt]
   e. In 5 + probable lag due timer firing interval
      i.e. say 5 minutes 10 seconds
      All will be forced shutdown by the timer call.
   g. DELETE file DoShut.txt
      or else no one will be able to get on.
* EOF:
Evaluate this to make others know how useful is this

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