MCI_OPEN does not work for mp3 files in a C ++ console application

This is what I did:

DWORD dwReturn; MCI_OPEN_PARMS mciOpenParms; mciOpenParms.lpstrDeviceType = _T("MPEGvideo"); mciOpenParms.lpstrElementName = m_tmpFileName; dwReturn = mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)(LPVOID) &mciOpenParms); if (dwReturn) { wchar_t chError[100]; mciGetErrorString(dwReturn,chError,sizeof(chError)); //report the error here } 

When I run the code, I see that dwReturn is 266, and chError is "An unknown problem while loading the specified device driver." What could be wrong?

Note. I also tried "mpegvideo" instead of "MPEGvideo"; It did not help. Where are all these documents documented?

+4
source share
2 answers

This works for me. Maybe (probably) you have an MCI register that messed things up. Or maybe the file you open is somehow corrupted.

As far as I know, these device names are not documented anywhere. But you can find those that are configured on your system in the registry: HKLM \ Software \ Microsoft \ Windows NT \ CurrentVersion \ MCI32 . My system has:

  • AVIVideo
  • Cdaudio
  • MPEGVideo
  • Sequencer
  • Waveaudio

And given that MCI is not used much today, I would say that they are pretty standard.

+1
source

If you specify MCI_OPEN_ELEMENT then mciOpenParms.lpstrDeviceType should be null.

See the Notes section.

* To use automatic type selection (via registry entries), assign the file name and file extension to the lpstrElementName member of the structure identified by lpOpen, set the lpstrDeviceType member to NULL, and set the MCI_OPEN_ELEMENT flag. *

+1
source

All Articles