Select Sound Card using mciSendCommand CSharp

Status
Not open for further replies.

islouis

Junior Member level 1
Joined
Sep 24, 2004
Messages
17
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
194
mci_wave_set_parms

Dear sir:

Im trying to use mciSendCommand to select one sound card for playing wave, another for recording, however, i read MSDN and other sample i still cant get it right, and i couldnt find any C# sample on the internet. my code as follow:


MCI_WAVE_SET_PARMS parms = new MCI_WAVE_SET_PARMS();
MCI_OPEN_PARMS OpenParms = new MCI_OPEN_PARMS();
OpenParms.lpstrDeviceType = "waveaudio";
OpenParms.lpstrElementName="C:\test.wav";
parms.wOutput = DeviceID;
rc= mciSendCommand (DeviceID, MCI_CLOSE, 0, null);
rc1 =mciSendCommand(DeviceID, MCI_OPEN, MCI_WAIT | MCI_OPEN_TYPE , OpenParms); // this cause exception!!!!!!!1
rc2 = mciSendCommand(DeviceID, MCI_SET, MCI_WAVE_OUTPUT, parms);
err=mciSendString("open c:/test.wav type waveaudio alias record", null, 0, IntPtr.Zero); // this 2 line will play the wave anyway
err=mciSendString("play record",null, 0, IntPtr.Zero);

Im unable to run this code, and it cause exception. May i know is there any sample i can use for selecting sound card programmaticly in c# or any hints and advice are welcome!
THANKS A LOT
LOUIS
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…