Thread: probe for drive letter assignment

  1. #1
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385

    probe for drive letter assignment

    in a windows console how can i get the drive letter of the available cd rom drive? Can i use one of the C++ functions or this going to be a windows specific function form windows headers?

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    this IS OS specific,

    the following code should find all the CD-ROM drives

    Code:
    #include <direct.h> //MSVC i don't know on other compilers...
    #include <windows.h>
    #include <stdio.h>
    
    int main(void)
    { 
        int i = 0;
        char buf[20];
        for(;i < 26;i++)
        {
            if(!_chdrive(i))
            {
                sprintf(buf,"%c:\\",i+ 'A' - 1);
                if(GetDriveType(buf) == DRIVE_CDROM)
                    printf("CD-ROM on Drive:%s",buf);// FOUND CD-ROM do whatever...
            }
    
        }
        return 0;
    }
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Registered User bljonk's Avatar
    Join Date
    Oct 2001
    Posts
    70

    wow!

    those developers!!!

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    direct.h isnt in UNIX, i believe ..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I ...
    By geekrockergal in forum C Programming
    Replies: 21
    Last Post: 02-07-2009, 10:40 AM
  2. counting letter occurences in a string
    By pjr5043 in forum C++ Programming
    Replies: 35
    Last Post: 05-05-2008, 09:18 PM
  3. help using strings and mapping
    By trprince in forum C Programming
    Replies: 29
    Last Post: 12-01-2007, 04:01 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. Replies: 1
    Last Post: 10-27-2006, 01:21 PM