Xref: news-dnh.mv.net comp.os.msdos.djgpp:4555 From: u7711501 AT bicmos DOT ee DOT nctu DOT edu DOT tw (Jih-Shin Ho) Newsgroups: comp.os.msdos.djgpp Subject: Re: Finding which drives exist Date: 20 Jan 1996 06:15:06 GMT Organization: Computer Center, National Chiao-Tung University, Taiwan Lines: 53 Message-ID: <4dq19a$3u0@ccnews.nctu.edu.tw> References: NNTP-Posting-Host: bicmos.ee.nctu.edu.tw NNTP-Posting-User: u7711501 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp A.Appleyard (A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk) wrote: : I wrote a big Gnu C++ program (an emacs-type text editor). I found today that : various DOS interrupts that are supposed to make specific fault returns when I : try to access a nonexistent drive, when Novell Netware is active act very odd : and cause aborts in my program; and I have to run with Novell active most of : the time. Luckily I have managed to cobble matters together so that a : nonexistent drive looks to a user of my program like an empty drive that can't : be written to. But this is unsatisfactory. Please how in Gnu C++ can I find : easily at run time for(i='A';i<='Z';i++) whether drive i exists? And I don't : want in the process any empty floppy or CD-ROM drives making rude noises at me : or wanting Abort/Fail/Retry. I don't mind if an empty floppy drive is treated : as nonexistent. It seems easy enough: the File Manager in Windows gets it : right every time and displays across the top of its window a row of little : disk drive icons, one for each existing logical drive. The following code is for Turbo-C. You can convert it to DJGPP style easily. It can detect physical drive and logical drive (for example, network drive). /* Find all system disk drives, for Turbo-C Written by Jih-Shin Ho, 1995 */ #include #include #include int main() { union REGS regs; int i; printf("Disk drive found : "); for (i = 0; i < 26; ++i) { regs.x.ax = 0x4409; /* get drive flags */ regs.h.bl = i + 1; /* 1-based dos drive */ intdos(®s,®s); if (!regs.x.cflag) printf("%c ",'A' + i); } printf("\n"); return(0); } -- Jih-Shin Ho, National Chiao Tung University u7711501 AT bicmos DOT ee DOT nctu DOT edu DOT tw DISPLAY -- universal image/movie viewer, converter, and indexer for DOS. Package name : disp???a.zip, disp???b.zip. ??? is version number. Official site : NCTUCCCA.edu.tw:/PC/graphics/disp. Other site : oak.oakland.edu:/SimTel/msdos/graphics. WWW page : http://bicmos.ee.nctu.edu.tw/