Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problem executing mci api

Hello,
I am having a problem while executing the mciSendCommand statement. I have just a few line of code in which I just play a .wav file. I am able to play it fine for the first time but as soon I make any change to the code it gives me:
(even when i just add coments)
Linking...
LINK : fatal error LNK1168: cannot open Debug/MciTest.exe for writing
Error executing link.exe.

MciTest.exe - 1 error(s), 0 warning(s)
I understand that there is a process running in the background but I have even used WM_DESTROY---PostQuitMessage(0) in my code.
When I try to use the Process viewer I am not able to remove the program of my .EXE.Why does the application does not get killed even by the Process viewer.
What could be the reason? How can I kill the process.
Thanks,
Khosla
I have just given a snipped of the code which is relevant:
#define MSG_LEN 1024

char msg[MSG_LEN+1];

MCIERROR rc;
UINT uDeviceId = 0;
MCI_OPEN_PARMS open;
MCI_PLAY_PARMS play;





case IDM_TEST:
{
// open waveform-audio device
//...........................
//............

open.dwCallback = (DWORD)hWnd;
open.lpstrDeviceType = "waveaudio";
open.lpstrElementName = "c:\Sample2.wav";

rc = mciSendCommand(0, MCI_OPEN,
MCI_OPEN_TYPE |
MCI_OPEN_ELEMENT,
(DWORD)&open);

if (rc)
{
mciGetErrorString(rc, msg, MSG_LEN);
MessageBox(hWnd, msg, NULL, MB_ICONSTOP|MB_OK);
return(0);
}

// play back sample2.wav
//......................

uDeviceId = open.wDeviceID;
play.dwCallback = (DWORD)hWnd;

rc = mciSendCommand(uDeviceId, MCI_PLAY, MCI_NOTIFY,(DWORD)&play);
}
break;

Thanks,

Khosla


Comments

  • could be off target here. but have u mciSendCommand( MCI_CLOSE ? i see u set the notify correctly for ur window. just wondering if u switch(message) case MM_MCINOTIFY switch(wParam) case MCI_NOTIFY_SUCCESSFUL:
    mciSendCommand( MCI_CLOSE );


    : Hello,
    : I am having a problem while executing the mciSendCommand statement. I have just a few line of code in which I just play a .wav file. I am able to play it fine for the first time but as soon I make any change to the code it gives me:
    : (even when i just add coments)
    : Linking...
    : LINK : fatal error LNK1168: cannot open Debug/MciTest.exe for writing
    : Error executing link.exe.
    :
    : MciTest.exe - 1 error(s), 0 warning(s)
    : I understand that there is a process running in the background but I have even used WM_DESTROY---PostQuitMessage(0) in my code.
    : When I try to use the Process viewer I am not able to remove the program of my .EXE.Why does the application does not get killed even by the Process viewer.
    : What could be the reason? How can I kill the process.
    : Thanks,
    : Khosla
    : I have just given a snipped of the code which is relevant:
    : #define MSG_LEN 1024
    :
    : char msg[MSG_LEN+1];
    :
    : MCIERROR rc;
    : UINT uDeviceId = 0;
    : MCI_OPEN_PARMS open;
    : MCI_PLAY_PARMS play;
    :
    :
    :
    :
    :
    : case IDM_TEST:
    : {
    : // open waveform-audio device
    : //...........................
    : //............
    :
    : open.dwCallback = (DWORD)hWnd;
    : open.lpstrDeviceType = "waveaudio";
    : open.lpstrElementName = "c:\Sample2.wav";
    :
    : rc = mciSendCommand(0, MCI_OPEN,
    : MCI_OPEN_TYPE |
    : MCI_OPEN_ELEMENT,
    : (DWORD)&open);
    :
    : if (rc)
    : {
    : mciGetErrorString(rc, msg, MSG_LEN);
    : MessageBox(hWnd, msg, NULL, MB_ICONSTOP|MB_OK);
    : return(0);
    : }
    :
    : // play back sample2.wav
    : //......................
    :
    : uDeviceId = open.wDeviceID;
    : play.dwCallback = (DWORD)hWnd;
    :
    : rc = mciSendCommand(uDeviceId, MCI_PLAY, MCI_NOTIFY,(DWORD)&play);
    : }
    : break;
    :
    : Thanks,
    :
    : Khosla
    :



  • Hello Sir,
    The problem was that I didnt use the MCI_CLOSE in the WM_DESTROY also . I used it only in the MM_MCINOTIFY.So when I closed the window while the song was still playing it didnt quit the MCI device and became a rogue process!
    I got a very good hint from your reply,
    Thanks
    Khosla


Sign In or Register to comment.