C# 如何一次从麦克风录制桌面和音频?

C# 如何一次从麦克风录制桌面和音频?,c#,winforms,C#,Winforms,我们需要建立一个应用程序,应该记录我们的桌面和麦克风在同一时间的音频。此文件需要自动保存在指定的路径中。我们尝试使用DLL windows media编码器构建应用程序。但我们面临的问题是,出现了一个弹出窗口,用于手动将节保存到系统文件夹中。这很好用。但是我们不需要显示弹出窗口和部分应该自动保存到指定的路径。我们在这里尝试过,但保存的部分缺少部分音频。有人能帮我们找到解决办法吗? 请检查以下代码, try { if (DesktopEncoder

我们需要建立一个应用程序,应该记录我们的桌面和麦克风在同一时间的音频。此文件需要自动保存在指定的路径中。我们尝试使用DLL windows media编码器构建应用程序。但我们面临的问题是,出现了一个弹出窗口,用于手动将节保存到系统文件夹中。这很好用。但是我们不需要显示弹出窗口和部分应该自动保存到指定的路径。我们在这里尝试过,但保存的部分缺少部分音频。有人能帮我们找到解决办法吗? 请检查以下代码,

     try
        {
            if (DesktopEncoder != null)
            {
                DesktopEncoder.Stop();
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter = "Video Files (*.wmv)|*.wmv";
                dialog.DefaultExt = "wmv";
                DialogResult res = dialog.ShowDialog();
                if (res != DialogResult.Cancel)
                {
                    if (File.Exists(DirectoryPath + "\\Demo\\tempScreenRecordVideo\\tempscreenvideo.wmv"))//ConfigurationSettings.AppSettings["demoTempScreenRecordVideo"]
                    {
                        recentRecordingsToolStripMenuItem1.DropDownItems.Add(dialog.FileName, null, recentRecordings_Click);
                        recentRecordingsToolStripMenuItem.DropDownItems.Add(dialog.FileName, null, recentRecordings_Click);
                        if (File.Exists(dialog.FileName))
                            File.Delete(dialog.FileName);

                        File.Copy(DirectoryPath + "\\Demo\\tempScreenRecordVideo\\tempscreenvideo.wmv", dialog.FileName);//ConfigurationSettings.AppSettings["demoTempScreenRecordVideo"]
                        if (DesktopEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_RUNNING && DesktopEncoder.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_PAUSED)
                        {
                            File.Delete(DirectoryPath + "\\Demo\\tempScreenRecordVideo\\tempscreenvideo.wmv");//ConfigurationSettings.AppSettings["demoTempScreenRecordVideo"]
                        }
                        if (File.Exists(DirectoryPath + "\\Demo\\ScreenRecordVideo\\screenvideo.wmv"))//ConfigurationSettings.AppSettings["demoScreenRecordVideo"]
                            File.Delete(DirectoryPath + "\\Demo\\ScreenRecordVideo\\screenvideo.wmv");//ConfigurationSettings.AppSettings["demoScreenRecordVideo"]
                        File.Copy(dialog.FileName, DirectoryPath + "\\Demo\\ScreenRecordVideo\\screenvideo.wmv");//ConfigurationSettings.AppSettings["demoScreenRecordVideo"]
                        File.Delete(dialog.FileName);
                    }
                }
                tmrRcCounter.Enabled = false;
                tsRecDuration.Text = "";
                tmrViewerCount.Enabled = false;
                if (this.Visible)
                {
                    notifyRecorder.Text = "Recorder is in Visible Mode.";
                }
                else
                {
                    notifyRecorder.Text = "Recorder is in Invisible Mode.";
                }
                //Windows Media Encoder EXE.
                Process[] ps = Process.GetProcessesByName("wmenc");
                if (ps.Length != 0)
                {
                    ps[0].Kill();
                }
                DesktopEncoder = null;
                tmrRcCounter.Enabled = false;
            }
        }
        catch
        {
            MessageBox.Show("Can't Stop it.Please,Save Current Recording and Restart Application.");
        }

然后不要显示对话,甚至不要创建对象,直接给出路径,如(“yourPath”)。它将保存并且不显示对话