/// <summary> /// 从当前位置开始或在一个指定区段中录音。 /// </summary> public void Record() { int err; int flags = 0; StringBuilder buf = new StringBuilder(1000); if (deviceID > 0 && (devCaps & DevCaps.CanRecord) == DevCaps.CanRecord) { if ((int)timer.Tag == 0) { timer.Tag = 1; timer.Start(); } MCI_RECORD_PARMS mrp = new MCI_RECORD_PARMS(); if (useFrom && startPos != 0) { mrp.dwFrom = startPos; flags |= MCI_FROM; useFrom = false; } if (useTo && endPos != 0) { mrp.dwTo = endPos; flags |= MCI_TO; useTo = false; } err = mciSendCommandA(deviceID, MCI_RECORD, flags, ref mrp); if (err != 0) { mciGetErrorStringA(err, buf, 1000); //throw new ApplicationException("录音出错," + buf.ToString()); } } else { //throw new ApplicationException("录音出错,打开的文件不能录音。"); } }
private static extern int mciSendCommandA( Int32 wDeviceID, UInt32 uMessage, Int32 dwParam, ref MCI_RECORD_PARMS Any);