home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!mimsy!nmrdc1!frmug!lill!vanney.raphael
- From: vanney.raphael@lill.frmug.fr.mugnet.org (Vanney Raphael)
- Newsgroups: comp.lang.pascal
- Subject: RE: CHECKING TO SEE IF A
- Message-ID: <966.6.uupcb@lill.frmug.fr.mugnet.org>
- Date: 20 Dec 92 19:29:00 GMT
- Reply-To: vanney.raphael@lill.frmug.fr.mugnet.org (Vanney Raphael)
- Organization: Li'LL BBS - Paris, France
- Lines: 86
-
-
- -=> Quoting Baker, Robert E. to All <=-
-
- BRE> From: BAKERRE@awc1.eglin.af.mil (Baker, Robert E.)
- BRE> Newsgroups: comp.lang.pascal
- BRE> Subject: Checking to see if a program is already loaded
- BRE> Date: 2 Dec 92 15:32:47 GMT
-
-
- BRE> I am currently writing a program (TP6) that has a DOS shell
- option.
- BRE> The question I have is this: how do I tell if the program is
- BRE> currently shelled to DOS to keep the user from trying to execute
- the
- BRE> program again while in the shell?
- BRE> I am somewhat familiar with the PSP, which is where I'm
- guessing(?)
- BRE> the solution lies. Am I correct?
- BRE> Any help (including source, or a pointer^ in the right direction)
- BRE> would be appreciated.
-
- BRE> ADVthanksANCE,
- BRE> Bob
- BRE> BAKERRE@TAWC1.EGLIN.AF.MIL
-
-
- BRE> -!- GEcho 1.00
- BRE> ! Origin: Li'LL BBS - Paris France - (33-1) 43.07.40.97 (2:320/7)
-
- Hello !
-
- Here is one solution, maybe not the best, but definitely working :
-
- Uses DOS,
- Objects ;
-
- Const
- IDString : String[20] = 'I''m the ID String !' ;
-
- Function AlreadyInHere : Boolean ;
- Var IdPt : PString Absolute 0:$ff*4 ;
- Begin
- AlreadyInHere:=IdPt^=IDString ;
- End ;
-
- Procedure TellImHere ;
- Begin
- SetIntVec($ff, @IDString) ;
- End ;
-
- Procedure TellImNotHereAnyMore ;
- Begin
- SetIntVec($ff, Nil) ;
- End ;
-
- Begin
- If AlreadyInHere Then
- Begin
- WriteLn('Re-entering this program would not be a good idea !')
- ;
- Halt(1) ;
- End ;
- TellImHere ;
-
- { Any stuff, such as DOS shelling... }
-
- TellImNotHereAnyMore ;
- End.
-
- If you feel like making something cleaner, you should save the old
- interrupt vector, make it point to your own Interrupt routine, which
- would in its turn call the old one ; the AlreadyInHere function should
- compare the code pointed to by INT $FF to the code of your own
- interrupt routine (Say, the 20 first bytes...), but this could be quite
- more difficult, since the few first bytes of an interrupt procedure
- contain the hard value of DS, which would be different in the two
- instances of your program...
-
- Raphael.
-
-
- ... Catch the Blue Wave!
- --- FMail 0.92
- * Origin: ICEBERG - La Garenne * FRANCE * Tel:(33)-1-47699261
- (2:320/1.0)
-
-