开发者

MCI_OPEN fails for mp3 files in a C++ console application

开发者 https://www.devze.com 2023-03-29 02:05 出处:网络
This is what I did: DWORD dwReturn; MCI_OPEN_PARMS mciOpenParms; mciOpenParms.lpstrDeviceType = _T(\"MPEGvideo\");

This is what I did:

DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
mciOpenParms.lpstrDeviceType = _T("MPEGvideo");
mciOpenParms.lpstrElementName = m_tmpFileName;

dwReturn = mciSe开发者_高级运维ndCommand(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 set to "Unknown problem while loading the specified device driver". What could be wrong?

Note: I also tried "mpegvideo" instead of "MPEGvideo"; it didn't help. Where are these things documented anyway?


It works for me. Maybe (likely) you have the MCI register all screwed up. Or maybe the file you are opening is corrupted somehow.

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

  • AVIVideo
  • CDAudio
  • MPEGVideo
  • Sequencer
  • WaveAudio

And given that the MCI is not used much nowadays, I'd say that they are pretty standard.


If you're specifying MCI_OPEN_ELEMENT then mciOpenParms.lpstrDeviceType must be null.

See the Remarks section.

*To use automatic type selection (via the entries in the registry), assign the filename 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.*

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号