虽然这个帖子很老了,但是觉得还是蛮有意思的,看了下MSDN找到解决办法了
写了如下的测试代码
private void button1_Click(object sender, EventArgs e)
{
this.button1.Text = "Do";
playSimpleSound(@"D:\Program Files\Tencent\QQ\sound\call.wav");
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.A)
{
button1_Click(sender, e);
}
}
private void playSimpleSound(String wavPath)
{
SoundPlayer simpleSound = new SoundPlayer(wavPath);
simpleSound.Play();
}
声音文件是在QQ安装目录随便找的,测试成功!