我需要播放mp3文件。我想使用winmm.dll(Windows 7)以C#播放音頻文件#
class Program
{
[DllImport("winmm.dll")]
private static extern long mciSendString(string Cmd, StringBuilder StrReturn, int ReturnLength, IntPtr HwndCallback);
static void Main(string[] args)
{
string FileName = @"F:\MUSIC\ROCK.mp3";
string CommandString = "open " + "\"" + FileName + "\"" + " type mpegvideo alias Mp3File";
mciSendString(CommandString, null, 0, IntPtr.Zero);
CommandString = "play Mp3File";
mciSendString(CommandString, null, 0, IntPtr.Zero);
Console.ReadKey();
}
}
但是當我運行我的程序時,什麼都沒有發生。 哪裏出錯?
你問過這個問題的同一個Sergey嗎? – 2010-11-11 18:58:19