Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing Multiple Instances of a Visual Foxpro Program

Status
Not open for further replies.

fmoore0001

Programmer
Dec 3, 2002
192
US
Guys, you all were a big help to me in developing routines to prevent multiple instances of a modeless form from running. Now, a another question. How do I prevent multiple instances of a Visual FoxPro program from running?

The legacy program I am working on can have multiple instances start on the same machine. Only ONE will run as I get table comflicts, but I would like the Visual Foxpro program, when starting, to detect the instance already running, then just such itself down.

I cannot find a Foxpro command to detect a prior running instance of a program, nor can I find a command in FOCUS.FLL, a library we use. Any ideas?

Frank
 
Opps. Did a FAQ check and found my answer in Ramai's excellant little addition to my program, as noted below and found in FAQ 184-839. It worked the first time and every time. And, whenever I close the one instance and then start another, it starts everytime. Perfectly.

=myInstance("A name for your Application")

Then just copy the following code and add it at the end of your main.prg.

******************************************
PROCEDURE myInstance
PARAMETERS myApp
=ddesetoption("SAFETY",.F.)
ichannel = DDEINITIATE(myapp,"ZOOM")
IF ichannel =>0
=DDETERMINATE(ichannel)
QUIT
ENDIF
=DDESETSERVICE(myapp,"define")
=DDESETSERVICE(myapp,"execute")
=DDESETTOPIC(myapp,"","ddezoom")
RETURN
ENDPROC
******************************************
PROCEDURE ddezoom
PARAMETER ichannel,saction,sitem,sdata,sformat,istatus
ZOOM WINDOW SCREEN NORM
RETURN
ENDPROC
**********************************************************
 
fmoore0001,

Glad the solution Ramani provided works well for you. I did a complete look at all the different ways to accomplish this and proposed some of my own in:

I've been working on some code with
thread184-672388

...just in case you'd like to look at everything is pretty much available in this forum for this.

boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Craig, thanks for the info. I will take a look at all of them. I was have liked (so far) about Ramani's routine is that 1) it lets me set up different programs easily, 2) Is very simple and 3) it works exactly like I have wanted it to. Does anyone no of cases here Ramani's program does not work? I have found only one- Don't try to run a test program and a installed program at the same time! I had to set up my test program NOT to do the check.

Frank

Frank
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top