這是針對Windows系統錄音軟體的小程式
目的是把聲音檔案的頻率轉換的低一些
嘗試過用WINDOWS API來做這個事,結果失敗了
最後還是用程式操作EXE檔案完成工作的
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiIml2ZuUWYxYmZhR2MiNjY3QGMjFGZlNTOzUWZjJGO2YzM1MWMfdWbp9CXt92Yu4GZjlGbh5SZslmZxl3Lc9CX6MHc0RHaiojIsJye.gif)
代碼
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 System.IO;
using System.Diagnostics;
using System.Threading;
namespace ShengYin2
{
public partial class Form1 : Form
public Form1()
InitializeComponent();
folderBrowserDialog1.ShowNewFolderButton = false;
}
private void button1_Click(object sender, EventArgs e)
DialogResult dr = folderBrowserDialog1.ShowDialog();
if (dr == DialogResult.OK)
label1.Text = "路徑:" + folderBrowserDialog1.SelectedPath;
private void button2_Click(object sender, EventArgs e)
Process myProc = new Process();
myProc.StartInfo.FileName = @"C:\wINDOWS\system32\sndrec32.exe";
myProc.StartInfo.UseShellExecute = false;
myProc.StartInfo.RedirectStandardInput = true;
myProc.Start();
DirectoryInfo di = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
FileInfo[] fis = di.GetFiles();
foreach (var a in fis)
if (a.Extension.Contains("wav"))
Thread.Sleep(600);
SendKeys.SendWait("%f");
SendKeys.SendWait("o");
SendKeys.SendWait(a.FullName);
SendKeys.SendWait("{Enter}");
SendKeys.SendWait("a");
SendKeys.SendWait("%c");
SendKeys.SendWait("{Down}");
myProc.Close();
MessageBox.Show("轉換完成");