I am working on codac application in Windows 7. Now somewhere in the middle this application calls this "waveOutOpen" function. But function is generating this MMSYSERR_BADDEVICEID error. In my PC no speaker is attached. The inbuilt speaker is not working. So the volume bar shows cross. But when I attach a headphone in the jack the Cross gets removed from the volumebar, that means that sound drivers are installed. Can someone tell me why this error is coming?
Although it is strange that in GetLastError it says operation completed successfullyCode:mr = waveOutOpen((LPHWAVEOUT)&m_hWaveOut,WAVE_MAPPER,(tWAVEFORMATEX*)&m_wavFmt,0L,0L,0L);
//if(mr != MMSYSERR_NOERROR)
if(mr == MMSYSERR_BADDEVICEID)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
return FALSE;
/*AfxMessageBox("Sound device open error !");
return FALSE;*/
}