中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-10-31 11:35
47,815 topics / 349,930 posts / today 0 new / 48,290 members
DOS开发编程 & 发展交流 (开发室) » How to write a program under DOS to detect whether a CD-ROM drive is installed?
Printable Version  8,299 / 45
Floor16 pfox Posted 2003-02-17 00:00
银牌会员 Posts 446 Credits 1,451
Although it's a bit troublesome, it's still a very good way to handle it (originally I just didn't want to use batch files again for conversion).

:)
Floor17 Lydong Posted 2003-02-20 00:00
元老会员 Posts 407 Credits 1,468 From 广州
Can FINDCD be enhanced further to implement the above function? That would save some trouble.
Floor18 Lydong Posted 2003-02-20 00:00
元老会员 Posts 407 Credits 1,468 From 广州
After running FINDCD, several lines of garbled text appear when using the SET command. Is that a problem with the program?
Floor19 Wengier Posted 2003-02-20 00:00
系统支持 Posts 10,521 Credits 27,736
What garbled text?
Floor20 Lydong Posted 2003-02-21 00:00
元老会员 Posts 407 Credits 1,468 From 广州
Floor21 Wengier Posted 2003-02-21 00:00
系统支持 Posts 10,521 Credits 27,736
All right, since that's the case, I enhanced it again and added the following options (note: only one option can be entered at a time):

/N: display on screen only, without setting the environment variable;
/Q: do not display on screen, only set the environment variable;
/?: help;
/S: set all mode (that is, the effect pfox and lydong wanted). For example, if there are two CD-ROM drives F and G, then after running FINDCD /S the result is:

CDROM=2
CDROM1=F:
CDROM2=G:

Note: if it runs normally, the ERRORLEVEL value is 0; otherwise it is 1 (no CD-ROM drive) or 2 (unable to set environment variable).

download link: Open attachment link expired (admin note 2009-4-28)

lydong: I have never noticed any garbled text, neither in pure DOS nor in a DOS window.


Floor22 Lydong Posted 2003-02-21 00:00
元老会员 Posts 407 Credits 1,468 From 广州
Thanks, Wengier. Your FINDCD is very easy to use now, and there is no garbled text anymore.
Floor23 pfox Posted 2003-02-22 00:00
银牌会员 Posts 446 Credits 1,451
Hehe, Wengier, the current findcd is already very complete, but I still want to make one more suggestion: since you use CDROM to store the number of Cdrom drives, why not directly set CDROM to 0 when there is no CD-ROM drive? Then there would be no need to use ERRORLEVEL to determine whether a CD-ROM drive exists, and you could directly check whether CDROM equals 0 to detect whether there is a CD-ROM drive. Sorry!
Floor24 Wengier Posted 2003-02-22 00:00
系统支持 Posts 10,521 Credits 27,736
Actually, here's how it is: if no CD-ROM drive exists, then while FINDCD sets ERRORLEVEL to 1, it will not set the CDROM variable. So to determine whether there is a CD-ROM drive is actually very simple: just run FINDCD and then check whether the CDROM variable exists. For example:

FINDCD
IF %CDROM%#==# ECHO No CDROM!

Or use the FINDCD 0 form. If no CD-ROM drive exists, the value of the CDROM variable will be 0.

However, if you mean that when running FINDCD /S with no CD-ROM drive, the value of the CDROM variable should be 0, then that is a good idea indeed. Is that what you mean?
Floor25 pfox Posted 2003-02-24 00:00
银牌会员 Posts 446 Credits 1,451
That's exactly what I mean. :)
Floor26 Wengier Posted 2003-02-24 00:00
系统支持 Posts 10,521 Credits 27,736
That's right, download link:
Open attachment link expired (admin note 2009-4-28)

Also, the latest MS-DOS 7.10 boot disk I made already includes this FINDCD. download link:
http://newdos.yginfo.net/dosware/mdos71bd.zip
Floor27 Lydong Posted 2003-04-07 00:00
元老会员 Posts 407 Credits 1,468 From 广州
Wengier :
I installed dual CD-ROM drives. I want AUTOEXEC.BAT to display the drive letter of the first CD-ROM drive when it runs, but after executing FINDCD, the displayed CDROM1 is the drive letter of the last CD-ROM drive instead. It shows as follows:

I:\>findcd /s
CDROM=2
CDROM1=L:
CDROM2=K:

I:\>

If the number of CD-ROM drives is uncertain, then determining the drive letter of the first CD-ROM drive is a bit difficult, unless you check the last CD-ROM drive letter.
But I think it would still be better to go in order, so I hope you can modify your program again.
Floor28 Wengier Posted 2003-04-07 00:00
系统支持 Posts 10,521 Credits 27,736
If it's the same CD-ROM device name (for example MSCD001), then the order really does get reversed. I'll go take a look. But if there are multiple CD-ROM device names, then it comes in order.
Floor29 Lydong Posted 2003-04-07 00:00
元老会员 Posts 407 Credits 1,468 From 广州
Can it be changed?
Floor30 Wengier Posted 2003-04-08 00:00
系统支持 Posts 10,521 Credits 27,736
I went back and looked at the FINDCD source program again. Unfortunately, first, those assembly code sections are very complicated to modify (and the CD-ROM drive letter list returned by function 150D of interrupt INT2F itself does not seem to be entirely in forward order), and second, I currently don't have dual CD-ROM drives with the same device name to test with (because for dual CD-ROM drives with different device names, it does come in order), so there's no way~~
Prev  1 2 3 4  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023