Click to See Complete Forum and Search --> : Pass a String to mciSendString("save recsound C://record1.wav", "", 0, 0);


ammusekar
May 30th, 2008, 01:08 AM
Hi..I want to record the wave files and want to store it in the specified location ,in which the user types the File Name in a TextBox.Im using the following code
to record & save.

[DllImport("winmm.dll", EntryPoint = "mciSendStringA",
CharSet = CharSet.Ansi, SetLastError = true,
ExactSpelling = true)
]
private static extern int mciSendString(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback);

private void btnrec_Click(object sender, EventArgs e)
{
mciSendString("open new Type waveaudio Alias recsound", null, 0,0);
mciSendString("record recsound","", 0, 0);

}
private void btnsave_Click(object sender, EventArgs e)
{

mciSendString("save recsound C://recordnew.wav","", 0, 0);
mciSendString("close recsound ","", 0, 0);
Computer c = new Computer();
timer1.Stop();
c.Audio.Stop();

}

I Tried to append via stringBuilder as
StringBuilder sb = new StringBuilder();
sb.Append("C://recordnew.wav");
mciSendString("save recsound sb","", 0, 0);
but its not geting recorded..
Kindly Pay attention..
Thanks in advance..

cilu
May 30th, 2008, 01:59 AM
Did you mean ""save recsound C:\\recordnew.wav"?

How is this supposed to work??

StringBuilder sb = new StringBuilder();
sb.Append("C://recordnew.wav");
mciSendString("save recsound sb","", 0, 0);

Well, I recommend you to check the return value of the function. That can give you an indication of what is wrong.

ChayKieu
May 30th, 2008, 07:42 AM
Sending commands using mcisendstring doesn't seem to work at all.
I send a string to play a wav file opened in a textbox. And nothing happens.
I have another button to press and play with PlaySound class and it works though.
This is really strange.