BBS: Inland Empire Archive Date: 03-28-93 (19:13) Number: 200 From: BOB PERKINS Refer#: NONE To: SEAN SULLIVAN Recvd: NO Subj: Re: Need a routine Conf: (2) Quik_Bas
SS> I know I've seen a routine for determining the directory
SS> from which a program was launched, but can't remember
SS> where. Anyone have this info?
'$INCLUDE: 'qb.bi'
DECLARE FUNCTION ExecPath$ ()
PRINT ExecPath$
FUNCTION ExecPath$
DIM regs AS regtype
regs.ax = &H6200
interrupt &H21, regs, regs
DEF SEG = regs.bx
DEF SEG = PEEK(44) + PEEK(45) * 256
byte% = 0
DO
IF PEEK(byte%) = 0 THEN
IF PEEK(byte% + 1) = 0 THEN byte% = byte% + 2: EXIT DO
END IF
byte% = byte% + 1
LOOP
IF PEEK(byte%) = 1 THEN
byte% = byte% + 2
DO WHILE PEEK(byte%)
temp$ = temp$ + CHR$(PEEK(byte%))
byte% = byte% + 1
LOOP
ExecPath$ = temp$
END IF
DEF SEG
END FUNCTION
--- Msg V4.5
* Origin: Reciprocity Failure (1:124/4115.236)

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