期末作業

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic.Devices;
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;

namespace WinFormsRecord
{
public partial class Form1 : Form
{
[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);

public Form1()
{
InitializeComponent();
}

private void btnRecord_Click(object sender, EventArgs e)
{
// record from microphone
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
}

private void btnSaveStop_Click(object sender, EventArgs e)
{
// stop and save
mciSendString("save recsound C:\\record.wav", "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
Computer c = new Computer();c.Audio.Stop();
}

private void btnRead_Click(object sender, EventArgs e)
{
Computer computer = new Computer();
computer.Audio.Play("C:\\record.wav", AudioPlayMode.Background);
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}