Strange error returned from mciSendString - Can anyone help?

1.8k Views Asked by At

A few months ago I added audio recording to a MFC app that I'm working on. This turned out to be easy enough and after an hour or two the code was working on my PC and on a couple of the customers test machines (one running XP the other Vista). Recently however one of their test machines was upgraded and now the recording feature refuses to work.

The basic code to start the recording is ..

mcierr=mciSendString("open new type waveaudio alias mysound",tmpstr,80,NULL);
mcierr=mciSendString("set mysound time format ms bitspersample 8 samplespersec 11025",tmpstr,80,NULL);
mcierr=mciSendString("record mysound",tmpstr,80,NULL);

which appears to work fine. To stop recording the following code is executed ..

mcierr=mciSendString("stop mysound",tmpstr,80,NULL);
mcierr=mciSendString("save mysound C:\\filename.wav",tmpstr,80,NULL);   
mcierr=mciSendString("close mysound",tmpstr,80,NULL);

The following error occurs when the "save mysound C:\filename.wav" instruction is sent. The error returned is ..

MCI Error A parameter or value was specified twice.  Only specify it once.

But I can't see any error in what I am sending and that error doesn't make sense. Is it possible that the error is because the program is trying to record using a format the PC doesn't support ?

Thanks for your time

Ian

2

There are 2 best solutions below

0
On

OK I managed to find a solution to this. This line in the code ..

mcierr=mciSendString("save mysound C:\\filename.wav",tmpstr,80,NULL); 

works fine on my development PC running XP but causes errors on some test PC's running XP and on all of them running Vista. The error goes away however if the filename itself is put within quotes like this ..

mcierr=mciSendString("save mysound "C:\\filename.wav"",tmpstr,80,NULL);

Now the code runs fine on all the XP and Vista PC's it has been tested on.

Ian

0
On

A detail more is necessary to have it working. Please watch the double "" before and after the file name:

mcierr=mciSendString("save mysound ""C:\\filename.wav""",tmpstr,80,NULL);

This is fine, too:

mcierr=mciSendString(@"save mysound ""C:\filename.wav""",tmpstr,80,NULL);

With these double quotation marks the code works on my Windows 7 now.