0

在 winfom C# 中使用 MCI 获取没有声音的 0 字节波形文件

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp4
{
    public partial class Form1 : Form
    {
        [DllImport("winmm.dll")]
        private static extern long mciSendString(string Command, string ReturnString, int ReturnLength, IntPtr Callback);
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            mciSendString("open new type WAVEAudio alias recsound", "", 0, IntPtr.Zero);
            mciSendString("record recsound", null, 0, IntPtr.Zero);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            mciSendString("save recsound C://temp.wav", null, 0, IntPtr.Zero);
            mciSendString("close recsound", null, 0, IntPtr.Zero);
        }
    }
}

到目前为止它工作正常,没有错误,因为我确实得到了在所需位置命名的 .wav 文件,但是它总是有 1KB 的大小让我认为我可能实际上并没有开始录制?

4

0 回答 0