Thread: Detecting CD drive letters in the Win32 API...

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Detecting CD drive letters in the Win32 API...

    I would like to know how I would go about detecting CD drive letters using the Win32 API. If you could, please show me an example!

    Thanks,
    Matt U.
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Code:
    #include <iostream>
    using std::cout;
    using std::endl;
    #include <windows.h>
    #include <string>
    using std::string;
    
    int main(int argc, char* argv[])
    { 
    	const string strLookup = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    	string strDrive;
    	DWORD dwBits = GetLogicalDrives();
    	const DWORD dwMask = 1;
    
    	for(int i = 0;i < strLookup.length();i++){
    		if(dwMask & dwBits){
    			strDrive = strLookup[i];
    			strDrive.append(":\\");
    				if(GetDriveType(strDrive.c_str()) == DRIVE_CDROM)
    					cout << "Found CDRom " << strDrive << endl;
    		}
    		dwBits >>= dwMask;
    	}
    
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CD drive not working
    By avgprogamerjoe in forum Tech Board
    Replies: 2
    Last Post: 10-24-2007, 08:55 PM
  2. Replies: 2
    Last Post: 09-06-2005, 02:37 AM
  3. This CD Drive is broken?
    By alphaoide in forum Tech Board
    Replies: 3
    Last Post: 06-04-2005, 02:59 PM
  4. drive letters
    By metsman20 in forum Tech Board
    Replies: 4
    Last Post: 12-11-2003, 12:54 PM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM