Click to See Complete Forum and Search --> : How can I get the CDROM drive name?


Deniz
August 5th, 2005, 03:05 AM
How can I get the CDROM drive name in a VC++ MFC project? ( the drive letter i.e. F:)



Thanks :)

NoHero
August 5th, 2005, 03:33 AM
Do you need the label? The drive letter? Or the vendor name?

GetDriveType() can help to achieve what drive type a specified drive letter is assigned to, and/or FindFirstVolume()/FindNextVolume(). To obtain the device label you can use GetVolumeInformation().

Have fun...

Deniz
August 5th, 2005, 03:40 AM
I want to do a shellexecute on a CDROM which means the autorun will call one executable and that executable will shellexecute one of a few other .exe programs depending on choice.

The cd rom drive may be different on each computer so I have to assume my program knows nothing about the computer.

Is there a way to find what the drive letter is which the CD Rom has been put in?

golanshahar
August 5th, 2005, 04:02 AM
you can use this simple code to find it.

for (int i='A'; i <= 'Z'; i++)
{
char szDrive[MAX_PATH];
::sprintf(szDrive,"%c:\\",i);
DWORD dwType = ::GetDriveType(szDrive);
if ( dwType == DRIVE_CDROM )
{
// CD-Rom Found;
break;
}
}


Cheers

Deniz
August 7th, 2005, 09:16 PM
Ok, that returns the drive letter of the first CD-ROM drive.

Lets assume there are more than one CDROM drive in the computer.

How do I find out which CDROM drive the actual CD is placed in?

golanshahar
August 8th, 2005, 03:24 AM
you can try figure it out with the ::mciSendString(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_mcisendstring.asp) using the status (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_status_mm.asp) command.

Cheers