声音文件播放问题
小鸟123 2012-10-27 05:25:34 public partial class Form1 : Form
{
string soundfileName;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = "E:\\Kugou\\";
openFileDialog1.Filter = "mp3 files|*.mp3|all files|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
soundfileName = openFileDialog1.FileName;
}
[DllImport("winmm.dll", EntryPoint = "PlaySound")]
public static extern bool PlaySound_DllImport(string pszSound, IntPtr hwnd, int fdwSound);
private void button2_Click(object sender, EventArgs e)
{
bool result;
System.IntPtr resourceHandle = System.IntPtr.Zero;
result = PlaySound_DllImport(soundfileName, resourceHandle, 0);
}
}
为什么我在使用button1按钮打开一个MP3文件后点击播放按钮即button2却不能播放呢,哪里有问题吗?求大神指教啊