TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: David Muir
from: Peter Fitzsimmons
date: 1995-09-02 03:04:12
subject: Not Communications

DM>     Is there a way of which you're aware to determine 
 DM> if a given drive is a 
 DM> CD-ROM (without attempting to write to the device

You can check the file system (CDFS).  Note that this will not tell you if
it it is a remote cdrom,  since the file system will be "LAN".

Why do you need to know if it is a cdrom?

Here's some code:


 // ICC /Ss /Kb /O /Rn qdisk.c
 #define INCL_NOPMAPI
 #define INCL_DOS
 #include 
 #include 
 #include 


 void errorRC(USHORT rc)
 {
     char msg[256];
     ULONG bc;
     if(0 != (rc=DosGetMessage(NULL, 0, msg, sizeof(msg), rc, "OSO001.MSG",
         &bc))){
                 printf("SYS%04u: Unable to access OSO001.MSG\n", rc);
     }
     else DosWrite(2, msg, bc, &bc);
 }

 void qdisk(char drv)
 {
     ULONG  rc, len;
     char dev[3];
     void *buf;
     char *p;
     FSQBUFFER2 *p2;

     if(drv < 'C')
         return;
     sprintf(dev, "%c:", drv);
     buf = malloc(2048);
     len = 2048;
     rc = DosQueryFSAttach(dev, 0, FSAIL_QUERYNAME, buf, &len);
     if(rc){
         errorRC(rc);
         return;
     }
     p2 = (FSQBUFFER2 *)buf;
     switch(p2->iType){
         case FSAT_CHARDEV  : printf("CHAR   "); break;
         case FSAT_PSEUDODEV: printf("DEV    "); break;
         case FSAT_LOCALDRV : printf("LOCAL  "); break;
         case FSAT_REMOTEDRV: printf("REMOTE "); break;
         default: printf("Unknown "); break;
     }
     p  = (char *)p2->szName;
     printf("%-3s ", p);     // szName
     p += p2->cbName + 1;
     printf("%-8s", p);      // szFSDName
     p += p2->cbFSDName + 1;
     if(p2->cbFSAData)
         printf(" %s", p);   // rgFSAData -- will show network path
                             // for Substp or Lan Server/Manager drive.
     printf("\n");
     free(buf);
 }

 void main(void)
 {
     char drv;
     ULONG usDisk;
     ULONG ulDrives;
     DosQueryCurrentDisk(&usDisk, &ulDrives);        /* get drive map */
     for (drv = 'A'; drv <= 'Z'; drv++) {
         if (ulDrives & 1)                   /* if the drive bit is set,  */
             qdisk(drv);                     /* check it out.             */
         ulDrives >>= 1;
     }
 }

--- Maximus/2 3.00
* Origin: Sol 3 * Toronto * V.32 * (905)858-8488 (1:259/414)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 259/414 400 99 250/99 3615/50 396/1 270/101 105/103 42 712/515
@PATH: 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.