Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 To: Glen Villar
  Where is Glen Villar?
 Palayan City
 Philippines
 Glen Villar
 Tags
Subject: RE: run app once
Thread ID: 365089 Message ID: 365484 # Views: 45 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Thursday, December 27, 2012 5:21:14 AM         
   


> > I think chester costa wants to run his application in one instance.
> >
> > Try this:
> >
> > This code should be placed in your MAIN.PRG.
> >
> > * The key is the table req_id.sys being created
> > * as soon as the program starts then USE it EXCLUSIVEly.
> > * req_id.sys (the table) could be any name you desire.
> > 
> > ***** Check single instance of app, my way *****
> > * See if table already exist
> > IF FILE(ADDBS(SYS(2023)) + "req_id.sys")
> >         * If table is already there, it was probably created by the previous instance of the app
> >         * but there might have been a crash or something that the app failed to delete it prior 
> >         * to a garceful exit
> > 	TRY 
> >                 * TRY to USE it EXCLUSIVEly so that succeeding program loads will not succeed in USEing it
> > 		USE (ADDBS(SYS(2023)) + "req_id.sys") EXCLUSIVE IN 0
> > 	CATCH TO oUseErr
> >                 * Check error number 1705 (aka "File access denied" error) which means
> >                 * another instance is already USEing the table
> > 		IF oUseErr.ERRORNO = 1705
> > 			MESSAGEBOX("Another instance of this application is already running.", ;
> > 				64, "System message")
> >                         * Do whatever you need to do here then...
> > 			QUIT
> > 		ENDIF
> > 	ENDTRY
> > ELSE
> >         * If table does not exist, create it with a different extension having only one field
> >         * This automatically opens it in EXCLUSIVE mode
> > 	CREATE TABLE (ADDBS(SYS(2023)) + "req_id.sys") ;
> > 		(prog_id C(10))
> >         * Just put any value in prog_id, it really doesn't matter
> > 	INSERT INTO req_id (prog_id) VALUES (SYS(2015))
> > ENDIF
> > ************************************************ 
> > 
> > DO FORM <yourloginform>

> >
> > Put these in your Close/Exit Buttons.
> >
USE IN req_id
> > ERASE (ADDBS(SYS(2023)) + "req_id.sys") 

> >
> > Hope it helps!:)
>
> Hi!
>
> With this code, you must have an utmost confidence in your UPS. Otherwise, any power interruption
> which will cause the PC to be closed immediately will make the codes in Close/Exit Buttons to be bypassed.
>
> If that happens, your login form may not load again unless you manually delete the req_id.sys. BTW, your name
> seems to be polymorphic? :-)
>
> Regards!
>
> (coffee)
> It's never too late to be who you might have been.
> -George Eliot. English Novelist (1819-1880)
>

> http://thereportersassistant.blogspot.com
> http://fruitypc.blogspot.com


Not only him but the OP him/herself.

Original name: Jem Carlo Mallari
Suddenly: Chester Costa

Participant:

Original Name: Carloid Costa (any relationship with Chester Costa?)
Suddenly: Carloid de Guzman

:-U


http://sandstorm36.blogspot.com
http://weblogs.foxite.com/sandstorm36

ENTIRE THREAD

run app once Posted by Jem Carlo Mallari @ 12/21/2012 8:38:51 AM
RE: run app once Posted by Jun Tangunan @ 12/21/2012 8:47:11 AM
RE: run app once Posted by Jem Carlo Mallari @ 12/21/2012 9:06:51 AM
RE: run app once Posted by Glen Villar @ 12/21/2012 1:58:40 PM
RE: run app once Posted by Cetin Basoz @ 12/21/2012 2:54:19 PM
RE: run app once Posted by Rick Hodgin @ 12/21/2012 4:41:09 PM
RE: run app once Posted by David Mustakim @ 12/21/2012 4:59:28 PM
RE: run app once Posted by David Mustakim @ 12/21/2012 4:10:24 PM
RE: run app once Posted by Tom Saddul @ 12/21/2012 4:22:10 PM
RE: run app once Posted by Carloid Costa @ 12/26/2012 8:22:36 AM
RE: run app once Posted by Glen Villar @ 12/26/2012 1:35:49 PM
RE: run app once Posted by Jun Tangunan @ 12/27/2012 5:21:14 AM
RE: run app once Posted by Tom Saddul @ 12/28/2012 10:15:49 AM