All right, below is part of the source code of this program:
Program initialization section (PASCAL source code):
program findcd;
const
env: arrayof Char='CDROM=c:'; <- prepares the environment variable
var
drvs: array of Char; <- CD-ROM character list
envp: PChar;
CD-ROM search subroutine (assembly source code):
procedure setdrv; assembler;
asm mov bx,0
mov ax,1500h
int 2fh <- calls interrupt to obtain CD-ROM status
cmp bx,1 <- checks whether the CD-ROM drive is installed
jc @@m <- if not, exit subroutine
push bx
push ds
pop es
mov bx,offset drvs
mov ax,150Dh
int 2Fh
pop cx
@@l: add byte ptr ,'A'
inc bx
loop @@l
mov byte ptr ,0
@@m:
end;
Add environment variable subroutine (assembly source code, omitted);
Main calling program (PASCAL source code):
begin
setdrv; <- calls the CD-ROM search subroutine;
if ord(drvs)=0 then <- if there is no CD-ROM drive, display “No CD-ROM found”;
WriteLn('No CD-ROM found.'

else begin
env:=drvs; <- if a CD-ROM drive exists, add the first CD-ROM drive letter to the environment variable CDROM;
WriteLn(env); <- display “CDROM=x:” on the screen;
if not InsertEnvVar <- calls the add environment variable subroutine;
then WriteLn('Cannot set environment variable!'

; <- if it cannot be added, display an error;
exit;
end;
end. <- program ends.