Click to See Complete Forum and Search --> : HOW TO: Multiple CD-ROM support with MCI
Michael Sieber
May 27th, 1999, 04:40 AM
Hello!
I need to support multiple CD-ROM drives in my application (definitly more than one!).
And have have to implement it with the MCI API.
My problem is that I cannot specify a certain device, e.g. a drive number or something like
that and the MCI_OPEN command takes the first drive it finds as the CD-ROM drive.
How can I open specific CD-ROM drives?
And keep more than one MCI device with MCI_DEVTYPE_CDAUDIO open?
Thanx for all hints and solutions!
Michael Sieber
Erlangen, Germany
Rauli Ikonen
May 30th, 1999, 03:47 PM
I wonder why would you want to support more than one CD-ROM drives, because (most likely) only one of them has connection to the sound card (the one MCI_OPEN selects, I suppose) and playing music with other CD-ROMs is therefore rather futile!
Todd Jeffreys
May 30th, 1999, 08:59 PM
Here is some code I have that will open an MCI CD audio device on a certain drive. Call it like SetDriveLetter("e:\\");
void CDMCIPlayer::SetDriveLetter(LPCTSTR drive)
{
//cDriveLetter is a global or whatever that stores the current drive letter assigned
if (cDriveLetter == *drive) return;
MCI_OPEN_PARMS mciOpen;
TCHAR szElementName[4];
TCHAR szAliasName[32];
DWORD dwFlags;
DWORD dwAliasCount = GetTickCount();
DWORD dwRet;
TCHAR chDrive;
chDrive = *drive;
ZeroMemory( &mciOpen, sizeof(mciOpen) );
if (dDeviceID)
{
mciSendCommand(dDeviceID,MCI_STOP,MCI_WAIT,0);
mciSendCommand(dDeviceID,MCI_CLOSE,MCI_WAIT,0);
}
mciOpen.lpstrDeviceType = (LPTSTR)MCI_DEVTYPE_CD_AUDIO;
wsprintf( szElementName, TEXT("%c:"), chDrive );
wsprintf( szAliasName, TEXT("CD%lu:"), dwAliasCount );
mciOpen.lpstrElementName = szElementName;
mciOpen.lpstrAlias = szAliasName;
dwFlags = MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE | MCI_OPEN_ALIAS |
MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | MCI_WAIT;
dwRet = mciSendCommand(0, MCI_OPEN, dwFlags, (DWORD)(LPVOID)&mciOpen);
if ( dwRet != MMSYSERR_NOERROR ) return;
cDriveLetter=chDrive;
dDeviceID=mciOpen.wDeviceID;
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.