BBS: Inland Empire Archive Date: 10-19-93 (11:06) Number: 39 From: HARRY F. HARRISON Refer#: 29 To: MARTIN BOUCHARD Recvd: NO Subj: ExeName Conf: (2) Quik_Bas
> Is there a way to retreive the directory where a program is > running? Here you go. '$INCLUDE: '..\include\qbx.bi' DECLARE FUNCTION LINSTR% (Offset%, In$, Search$) DECLARE SUB UnNull (In$) DECLARE FUNCTION Trim$ (In$) DEFSNG A-Z SUB GetCmdLine (PathName$, ProgName$, CmdLine$, Segment%) DIM Inregs AS RegType, OutRegs AS RegType Inregs.ax = &H6200 CALL Interrupt(&H21, Inregs, OutRegs) DEF SEG = OutRegs.bx EnvLo% = PEEK(&H2C) EnvHi% = PEEK(&H2D) CmdTailLen% = PEEK(&H80) FOR tmp% = &H81 TO ((&H81 + CmdTailLen%) - 1) CommandTail$ = CommandTail$ + CHR$(PEEK(tmp%)) NEXT tmp% DEF SEG = EnvLo% + (EnvHi% * 256) PPointer% = 0 DO UNTIL PEEK(PPointer%) = 0 DO UNTIL PEEK(PPointer%) = 0 Environment$ = Environment$ + CHR$(PEEK(PPointer%)) PPointer% = PPointer% + 1 LOOP Environment$ = Environment$ + CHR$(255) PPointer% = PPointer% + 1 LOOP PPointer% = PPointer% + 3 DO UNTIL PEEK(PPointer%) = 0 ProgramName$ = ProgramName$ + CHR$(PEEK(PPointer%)) PPointer% = PPointer% + 1 LOOP DEF SEG PathLen% = LEN(ProgramName$) PathName$ = Trim$(LEFT$(ProgramName$, LINSTR(0, ProgramName$, "\"))) ProgName$ = Trim$(MID$(ProgramName$, LINSTR(0, ProgramName$, "\") + 1)) CmdLine$ = Trim$(CommandTail$) Segment% = OutRegs.bx END SUB DEFINT A-Z FUNCTION Trim$ (In$) Out$ = LINSTR(In$, CHR$(0), CHR$(32)) Trim$ = LTRIM$(RTRIM$(Out$)) END FUNCTION DEFINT A-Z FUNCTION LINSTR (Offset%, In$, Search$) IF Offset% = 0 THEN Offset% = LEN(In$) DO A = x x = INSTR(x + 1, In$, LEFT$(Search$, Offset%)) LOOP WHILE x > 0 LINSTR = A END FUNCTION $$ --- FMail 0.94 * Origin: To ring or not to ring ... what was the question? (3:635/572)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET