BBS: Inland Empire Archive Date: 11-20-92 (11:08) Number: 336 From: TONY ELLIOTT Refer#: NONE To: DENNIS POWERS Recvd: NO Subj: Re: .EXE file reading its Conf: (2) Quik_Bas
TE>better off putting it in a seperate file. I have some code that TE>will tell you the drive/path of the .exe file currently running, so TE>it's easy to locate your data as well. Let me know if you need it. DP> This bit of code would be real handy! If it's not too large or too DP> much trouble to post I would like to see it. Thanks. Here you go. One note.. If you use this routine from within the QB/QBX/VBDOS IDE, the program path/name that will be returned is that of the IDE itself. Good luck! DEFINT A-Z DECLARE FUNCTION ExeName$ () 'Declare our function REM $INCLUDE: 'QBX.BI' 'Use QB.BI if running QB4.x PRINT "Program name is: "; ExeName$ FUNCTION ExeName$ DIM Reg AS RegType 'Get ready for CALL INTERRUPT Reg.ax = &H5100 'DOS function 51h - get PSP CALL Interrupt(&H21, Reg, Reg) DEF SEG = Reg.bx EnvSeg% = PEEK(&H2C) + PEEK(&H2D) * 256 'Get address to environment DEF SEG = EnvSeg% DO Value% = PEEK(Offset%) 'Look at each character IF Value% = 0 THEN 'All entries ASCIZ terminated Count% = Count% + 1 IF Count% AND ExeFlag% THEN 'Name of our .EXE also ASCIZ EXIT DO 'Exit when we reach the end ELSEIF Count% = 2 THEN 'Last entry in environment terminated ExeFlag% = -1 'with two CHR$(0)'s. Two bytes ahead Offset% = Offset% + 2 'is the .EXE file name. Set flag. END IF ELSE 'If Value%<>0 then reset the Count% = 0 ' zero counter. IF ExeFlag% THEN 'If looking at EXE name, build string. Temp$ = Temp$ + CHR$(Value%) END IF END IF Offset% = Offset% + 1 LOOP DEF SEG 'Don't forget this! ExeName$ = Temp$ 'Assign our temp$ to the function END FUNCTION ... Take a bite out of crime .. Abolish the IRS! --- Blue Wave/Max v2.10 [NR] * Origin: Oakland BBS - McDonough, GA - (404) 954-0071 (1:133/706.0)
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