Detecting CD drive letters in the Win32 API...

This is a discussion on Detecting CD drive letters in the Win32 API... within the Windows Programming forums, part of the Platform Specific Boards category; I would like to know how I would go about detecting CD drive letters using the Win32 API. If you ...

  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: trifaze_mattu@lycos.com

    ---------------------------------
    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,789
    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, 09:55 PM
  2. Replies: 2
    Last Post: 09-06-2005, 03:37 AM
  3. This CD Drive is broken?
    By alphaoide in forum Tech Board
    Replies: 3
    Last Post: 06-04-2005, 03: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, 06:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21