I wrote following code:
using System.Runtime.InteropServices;
[DllImport("winmm.dll")]
public static extern int mciSendString(string lpstrCommand, string
lpstrReturnString,int uReturnLength,
int dwCallback);
[DllImport("winmm.dll")]
public static extern int mciGetErrorString(int errCode,string errMsg,uint
buflen);
private void btnPlay_Click(object sender, System.EventArgs e)
{
int r1,r2;
string s1,s2;
string Playingfile;
s1="";
s2="";
Playingfile=listBox1.SelectedItem.ToString();
r1=mciSendString("OPEN "+Playingfile+" TYPE Sequencer wait","",0,0);
r2=mciSendString("PLAY "+Playingfile,"",0,0);
mciGetErrorString(r1,s1,128);
mciGetErrorString(r2,s2,128);
MessageBox.Show("s1="+s1 +" s2="+s2+" r1="+r1.ToString()+"
r2="+r2.ToString());
}
The MessageBox shows s1 s2 are empty string, while r1=0 and r2=337.
I don't know what the return value 337 mean.
I just want to play a MIDI file in C#. any better way?
Waiting for reply. Thanks.