China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 04:26
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » How to write a program under DOS to detect whether a CD-ROM drive is installed? View 7,324 Replies 45
Floor 16 Posted 2003-02-17 00:00 ·  中国 广东 汕头 电信
银牌会员
★★★
Credits 1,451
Posts 446
Joined 2002-10-20 00:00
23-year member
UID 29
Gender Male
Status Offline
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).

:)
Floor 17 Posted 2003-02-20 00:00 ·  中国 广东 广州 增城区 电信
元老会员
★★★
Credits 1,468
Posts 407
Joined 2002-10-21 00:00
23-year member
UID 34
Gender Male
From 广州
Status Offline
Can FINDCD be enhanced further to implement the above function? That would save some trouble.
欢迎大家观临我的个人主页:

http://dosdiy.bluepc.com.cn/
http://dosdiy.ys168.com/


EMAIL: lydong@china.com.cn lydong@yeah.net
----------------------------------------------
Floor 18 Posted 2003-02-20 00:00 ·  中国 广东 广州 增城区 电信
元老会员
★★★
Credits 1,468
Posts 407
Joined 2002-10-21 00:00
23-year member
UID 34
Gender Male
From 广州
Status Offline
After running FINDCD, several lines of garbled text appear when using the SET command. Is that a problem with the program?
欢迎大家观临我的个人主页:

http://dosdiy.bluepc.com.cn/
http://dosdiy.ys168.com/


EMAIL: lydong@china.com.cn lydong@yeah.net
----------------------------------------------
Floor 19 Posted 2003-02-20 00:00 ·  加拿大 Telus
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
What garbled text?
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 20 Posted 2003-02-21 00:00 ·  中国 广东 广州 增城区 电信
元老会员
★★★
Credits 1,468
Posts 407
Joined 2002-10-21 00:00
23-year member
UID 34
Gender Male
From 广州
Status Offline
欢迎大家观临我的个人主页:

http://dosdiy.bluepc.com.cn/
http://dosdiy.ys168.com/


EMAIL: lydong@china.com.cn lydong@yeah.net
----------------------------------------------
Floor 21 Posted 2003-02-21 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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.


Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 22 Posted 2003-02-21 00:00 ·  中国 广东 广州 增城区 电信
元老会员
★★★
Credits 1,468
Posts 407
Joined 2002-10-21 00:00
23-year member
UID 34
Gender Male
From 广州
Status Offline
Thanks, Wengier. Your FINDCD is very easy to use now, and there is no garbled text anymore.
欢迎大家观临我的个人主页:

http://dosdiy.bluepc.com.cn/
http://dosdiy.ys168.com/


EMAIL: lydong@china.com.cn lydong@yeah.net
----------------------------------------------
Floor 23 Posted 2003-02-22 00:00 ·  中国 广东 汕头 电信
银牌会员
★★★
Credits 1,451
Posts 446
Joined 2002-10-20 00:00
23-year member
UID 29
Gender Male
Status Offline
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!
Floor 24 Posted 2003-02-22 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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?
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 25 Posted 2003-02-24 00:00 ·  中国 广东 汕头 电信
银牌会员
★★★
Credits 1,451
Posts 446
Joined 2002-10-20 00:00
23-year member
UID 29
Gender Male
Status Offline
That's exactly what I mean. :)
Floor 26 Posted 2003-02-24 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 27 Posted 2003-04-07 00:00 ·  中国 广东 广州 增城区 电信
元老会员
★★★
Credits 1,468
Posts 407
Joined 2002-10-21 00:00
23-year member
UID 34
Gender Male
From 广州
Status Offline
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.
欢迎大家观临我的个人主页:

http://dosdiy.bluepc.com.cn/
http://dosdiy.ys168.com/


EMAIL: lydong@china.com.cn lydong@yeah.net
----------------------------------------------
Floor 28 Posted 2003-04-07 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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.
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 29 Posted 2003-04-07 00:00 ·  中国 广东 广州 增城区 电信
元老会员
★★★
Credits 1,468
Posts 407
Joined 2002-10-21 00:00
23-year member
UID 34
Gender Male
From 广州
Status Offline
Can it be changed?
欢迎大家观临我的个人主页:

http://dosdiy.bluepc.com.cn/
http://dosdiy.ys168.com/


EMAIL: lydong@china.com.cn lydong@yeah.net
----------------------------------------------
Floor 30 Posted 2003-04-08 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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~~
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Forum Jump: