我正在尝试使用DOS API“ EXEC”(int 21h,AH = 4Bh)来加载程序。我尝试了几件事,但是没有用。我正在得到结果代码AX = 2,表示“找不到文件”。我认为param块有些不正确,但是我不确定是什么。您对如何使代码正常工作有任何建议吗?
这是我到目前为止尝试过的:
CLS
DIM Array(0 TO 127) AS INTEGER
DEF SEG = VARSEG(Array(0))
TYPE paramblk
segenv AS INTEGER
cmdline AS INTEGER
cseg AS INTEGER
fcb1 AS INTEGER
f1seg AS INTEGER
fcb2 AS INTEGER
f2seg AS INTEGER
END TYPE
TYPE RegTypeX
ax AS INTEGER
bx AS INTEGER
cx AS INTEGER
dx AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
flags AS INTEGER
ds AS INTEGER
es AS INTEGER
END TYPE
DIM regs AS RegTypeX
DIM p AS paramblk
cmdline$ = CHR$(0) + "" + CHR$(&HD)
emptyfcb$ = CHR$(0) + "???????????" + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + _
CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0)
p.segenv = 0 ' 0 = copy environment of parent
p.cmdline = SADD(cmdline$)
p.cseg = SSEG(cmdline$)
p.fcb1 = SADD(emptyfcb$)
p.f1seg = SSEG(emptyfcb$)
p.fcb2 = SADD(emptyfcb$)
p.f2seg = SSEG(emptyfcb$)
REM I tried both of these
CHNAME$ = "AYDOS1.EXE" + CHR$(0)
REM chname$ = "C:\QB71\AYDOS1.EXE" + CHR$(0)
regs.ax = &H4B00
regs.ds = SSEG(CHNAME$)
regs.dx = SADD(CHNAME$)
regs.es = VARSEG(p)
regs.bx = VARPTR(p)
CALL interrupt(&H21, regs, regs)
PRINT "AX = ", regs.ax ' I am receiving AX=2 (File not found) as result
注意:我没有使用SHELL
命令,因为使用EXEC API,我想在进一步的步骤中调用非EXE文件
注2:环境为DOSBox,并且我正在使用QuickBasic 7.1(带有选项/ L)