Hi all. A long time ago I found a sample QuickBasic program that could basically check it's own name. I meant to save it but now I can't find it.
Now I'm trying to make a program with quite a bit of imbedded binary data. The best way I can think of is to tack it on the end of the exe and have it OPEN itself to get it, but I want it to work even if it's been renamed, so...
Does anyone happen to know how to do this? Or if not can anyone thing of another clever solution?
Basically what I'm trying to create, if anyone is interested, is a self-displaying image file.
Determine the name of the running executable.
Checking the currently running EXE file name
Code for checking the EXE file name
Running this code from within QB returns the path name where QB is running from plus "QB.EXE". Running this code from a stand-alone exe returns the path where the exe file is running from plus the file's name.
Original Code by by Tomppa: http://www.fys.ruu.nl/~bergmann/file.bas
QB.LIB File: http://student.fsb.hr/download/sharewar ... /qb/qb.lib
QB.BI File: http://student.fsb.hr/download/sharewar ... g/qb/qb.bi
Further Reading
How to Use CALL INTERRUPT with QB: http://support.microsoft.com/default.as ... n-us;43534
Code: Select all
DECLARE FUNCTION exename$ ()
DEFINT A-Z
CONST true = -1, false = 0
' $INCLUDE: 'qb.bi'
PRINT exename$
REM $DYNAMIC
FUNCTION exename$
'
' This function returns the name of the exefile which is running
'
DIM regs AS RegTypeX
tmp$ = ""
regs.ax = &H6200
CALL InterruptX(&H21, regs, regs)
DEF SEG = regs.bx
DEF SEG = PEEK(&H2C) + PEEK(&H2D) * 256
byte = 0
DO
IF PEEK(byte) = 0 THEN
IF PEEK(byte + 1) = 0 THEN
byte = byte + 2
EXIT DO
END IF
END IF
byte = byte + 1
LOOP
IF PEEK(byte) = 1 THEN
byte = byte + 2
DO WHILE PEEK(byte)
tmp$ = tmp$ + CHR$(PEEK(byte))
byte = byte + 1
LOOP
exename$ = tmp$
END IF
END FUNCTION
Original Code by by Tomppa: http://www.fys.ruu.nl/~bergmann/file.bas
QB.LIB File: http://student.fsb.hr/download/sharewar ... /qb/qb.lib
QB.BI File: http://student.fsb.hr/download/sharewar ... g/qb/qb.bi
Further Reading
How to Use CALL INTERRUPT with QB: http://support.microsoft.com/default.as ... n-us;43534