Launching an exe from FoxPro

Launching an exe from FoxPro

Post by Brian Mantl » Sat, 01 Apr 1995 04:00:00




Quote:> I would like to launch and executable program from forpro be able to
> detect when the user has exited the application(to prevent the user from
> launching multiple copies). Is it possible to do this ? If so how would I go
> about doing this ?

> Any email / help/ suggestions will be greatly appreciated.

> Singh
> --
>                /_\

Try using the Foxpro RUN (!) command to launch your second applicaton.

Along another lne of attack you can try somethn like the following:
When you start the FoxPro applicaton open a datbase (call it inuse.dbf)

Insert a new record with the username/id, workstation number, and time-in.
Also have a logical field named "in_use", mark ths .t.  Everytime they try
to launch the application check to see if that user has a record where
"in_use=.t.", if they do then quit there.

Of course when they logout you must toggle in_use to .f.

A simplier method would be to just open an empty database excl on startup.
 If you cannot open it then you quit.  This will allow only one person to
use the applicaton at one time.

--
-- Brian Mantler

 
 
 

Launching an exe from FoxPro

Post by Prima Computer Syste » Sat, 01 Apr 1995 04:00:00


I would like to launch and executable program from forpro be able to
detect when the user has exited the application(to prevent the user from
launching multiple copies). Is it possible to do this ? If so how would I go
about doing this ?

Any email / help/ suggestions will be greatly appreciated.

Singh
--
               /_\
             / / \ \
            ( /o o\ )
             (  U  )
     .oOOo----\_-_/-----oOOo--,
   /_|    Santheep Singh      ||

  |  Prima Computer Systems   ||
  `-------.ooO-----Ooo.-------'|
    `-----(   )---(   )--------'
           \ (     ) /
            \_)   (_/

 
 
 

Launching an exe from FoxPro

Post by Scott Barke » Fri, 07 Apr 1995 04:00:00



> > I would like to launch and executable program from forpro be able to
> > detect when the user has exited the application(to prevent the user from
> > launching multiple copies). Is it possible to do this ? If so how would I go
> > about doing this ?

> > Any email / help/ suggestions will be greatly appreciated.

> > Singh
> > --

I found this program on CServe a while ago.  I have changed it a little
but I can't find the author's orig!  I'd rather he got credit for
this, as it's a nice work-around.  It involves using run and then
registering a FindWindow function to test for the presence of the
launched app.  Works ok and is pretty easy to take this idea and
change it to suit your needs...

Here's the fragment:

Cheers!  Scott.
***********************************************
*** App. Launch/Wait test...
*** Use run to launch other win app
*** WaitForme function uses registered win function
*** thru' foxtools-fll to look for app presence...
*** via the window name...

*** launch win app...
rhcmd= "/N1 mviewer2.exe "+DatDrv+"mvtitle"
run &rhcmd

x = waitforme("mviewer2")

return
***********************************************
*------------------------------------------------------------------------------
FUNCTION WaitForMe              && this program waits until a windows program is done
PARAMETER dowhat
PRIVATE   dowhat, getwind, wclass, winname, pmhand, howquit, seconds, key
*------------------------------------------------------------------------------
* The loop tests for the presence of the external window every 'n_sec' seconds.
* this does not place the computer in a continious loop and with the 'wait' statement
* provides some feedback to the user that at least something is hapening. Both external
* applications are self terminating. When the window is no longer found the loop is broken.
*------------------------------------------------------------------------------
SET LIBRARY TO SYS(2004)+"foxtools.fll" ADDITIVE
m.dowhat = LOWER(ALLTRIM(m.dowhat))
DO CASE
        CASE m.dowhat = 'procomm'
                m.winname    = "PROCOMM PLUS for Windows"     && name of the application window
                m.message = 'Waiting for ProComm to complete transmission.'
        CASE m.dowhat = 'mviewer2'
        m.winname    = "Database Viewer System"
        m.message = 'Waiting for viewer to close ...'
        OTHERWISE
                RETURN .t.
ENDCASE

m.message = m.message +CHR(13)+ 'Press "C" to continue....' +CHR(13)+ 'Seconds = '
m.getwind = Regfn("FindWindow", "CC", "I")
m.wclass  = 0
m.pmhand  = 1
m.howquit = .f.         && .f. = normal termination, .t. = user termination
m.seconds = 0           && count the seconds that have passed & display to the user
m.n_sec   = 05          && seconds to wait before testing the loop again
*----------------------------
DO WHILE m.pmhand <> 0
        WAIT WINDOW m.message + ALLTRIM(STR(m.seconds)) TO m.key TIMEOUT m.n_sec
        m.seconds = m.seconds + m.n_sec
        IF UPPER(m.key) = 'C'           && exit loop on Q key
                m.howquit = .t.
                EXIT
        ENDIF
        m.pmhand = callfn(m.getwind, m.wclass, m.winname)
ENDDO
RELEASE LIBRARY SYS(2004)+"foxtools.fll"
*------------------------------------------------------------------------------
RETURN m.howquit                && if .t., user quit the process.
*------------------------------------------------------------------------------