CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    1

    HOW TO: Multiple CD-ROM support with MCI

    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


  2. #2
    Join Date
    Apr 1999
    Location
    Finland
    Posts
    68

    Re: HOW TO: Multiple CD-ROM support with MCI

    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!


  3. #3
    Join Date
    Apr 1999
    Posts
    396

    Re: HOW TO: Multiple CD-ROM support with MCI

    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;
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured