home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7642 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.6 KB

  1. Path: sparky!uunet!haven.umd.edu!mimsy!nmrdc1!frmug!lill!vanney.raphael
  2. From: vanney.raphael@lill.frmug.fr.mugnet.org (Vanney Raphael)
  3. Newsgroups: comp.lang.pascal
  4. Subject: RE: CHECKING TO SEE IF A
  5. Message-ID: <966.6.uupcb@lill.frmug.fr.mugnet.org>
  6. Date: 20 Dec 92 19:29:00 GMT
  7. Reply-To: vanney.raphael@lill.frmug.fr.mugnet.org (Vanney Raphael)
  8. Organization: Li'LL BBS - Paris, France
  9. Lines: 86
  10.  
  11.  
  12.  -=> Quoting Baker, Robert E. to All <=-
  13.  
  14.  BRE> From: BAKERRE@awc1.eglin.af.mil (Baker, Robert E.)
  15.  BRE> Newsgroups: comp.lang.pascal
  16.  BRE> Subject: Checking to see if a program is already loaded
  17.  BRE> Date: 2 Dec 92 15:32:47 GMT
  18.  
  19.  
  20.  BRE> I am currently writing a program (TP6) that has a DOS shell
  21. option.
  22.  BRE> The question I have is this:  how do I tell if the program is
  23.  BRE> currently shelled to DOS to keep the user from trying to execute
  24. the
  25.  BRE> program again while in the shell?
  26.  BRE> I am somewhat familiar with the PSP, which is where I'm
  27. guessing(?)
  28.  BRE> the solution lies.  Am I correct?
  29.  BRE> Any help (including source, or a pointer^ in the right direction)
  30.  BRE> would be appreciated.
  31.  
  32.  BRE> ADVthanksANCE,
  33.  BRE> Bob
  34.  BRE> BAKERRE@TAWC1.EGLIN.AF.MIL
  35.  
  36.  
  37.  BRE> -!- GEcho 1.00
  38.  BRE>  ! Origin: Li'LL BBS - Paris France - (33-1) 43.07.40.97 (2:320/7)
  39.  
  40. Hello !
  41.  
  42. Here is one solution, maybe not the best, but definitely working :
  43.  
  44. Uses DOS,
  45.      Objects ;
  46.  
  47. Const
  48.      IDString  : String[20] = 'I''m the ID String !' ;
  49.  
  50. Function AlreadyInHere : Boolean ;
  51. Var  IdPt : PString Absolute 0:$ff*4 ;
  52. Begin
  53.      AlreadyInHere:=IdPt^=IDString ;
  54. End ;
  55.  
  56. Procedure TellImHere ;
  57. Begin
  58.      SetIntVec($ff, @IDString) ;
  59. End ;
  60.  
  61. Procedure TellImNotHereAnyMore ;
  62. Begin
  63.      SetIntVec($ff, Nil) ;
  64. End ;
  65.  
  66. Begin
  67.      If AlreadyInHere Then
  68.      Begin
  69.           WriteLn('Re-entering this program would not be a good idea !')
  70. ;
  71.           Halt(1) ;
  72.      End ;
  73.      TellImHere ;
  74.  
  75.      { Any stuff, such as DOS shelling... }
  76.  
  77.      TellImNotHereAnyMore ;
  78. End.
  79.  
  80. If you feel like making something cleaner, you should save the old
  81. interrupt vector, make it point to your own Interrupt routine, which
  82. would in its turn call the old one ; the AlreadyInHere function should
  83. compare the code pointed to by INT $FF to the code of your own
  84. interrupt routine (Say, the 20 first bytes...), but this could be quite
  85. more difficult, since the few first bytes of an interrupt procedure
  86. contain the hard value of DS, which would be different in the two
  87. instances of your program...
  88.  
  89.                                              Raphael.
  90.  
  91.  
  92. ... Catch the Blue Wave!
  93. --- FMail 0.92
  94.  * Origin: ICEBERG - La Garenne * FRANCE * Tel:(33)-1-47699261
  95. (2:320/1.0)
  96.                                                                                    
  97.