我是在windows 2000下测试通过
void CMyDlg::OnOpenCD() 
{
// TODO: Add your control notification handler code here UINT wDeviceID;
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;

// Opens a CD audio device by specifying the device name.

mciOpenParms.lpstrDeviceType = "cdaudio";

if (dwReturn = mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_TYPE,
(DWORD)(LPVOID) &mciOpenParms))
{
mciSendCommand(mciGetDeviceID("cdaudio"), MCI_SET, MCI_SET_DOOR_OPEN, NULL);
/* char szErrorBuf[MAXERRORLENGTH];
MessageBeep(MB_ICONEXCLAMATION);
if(mciGetErrorString(dwReturn, (LPSTR) szErrorBuf, MAXERRORLENGTH))
{
MessageBox(szErrorBuf, "MCI Error",
MB_ICONEXCLAMATION);
}
else
{
MessageBox("Unknown Error", "MCI Error",
MB_ICONEXCLAMATION);
}*/
}

// The device opened successfully; get the device ID.
wDeviceID = mciOpenParms.wDeviceID; mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, NULL);
}void CMyDlg::OnCloseCD() 
{
mciSendCommand(mciGetDeviceID("cdaudio"), 
MCI_SET, MCI_SET_DOOR_CLOSED, (DWORD)(LPVOID)&StatusParms);
}

解决方案 »

  1.   

      还是不能用啊? 
    vc报告如下的错误:
      Linking...
    opencdDlg.obj : error LNK2001: unresolved external symbol __imp__mciGetDeviceIDA@4
    opencdDlg.obj : error LNK2001: unresolved external symbol __imp__mciSendCommandA@16
    Debug/opencd.exe : fatal error LNK1120: 2 unresolved externals
    Error executing link.exe.  为什么?