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.
Printable View
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.
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;
}