111,094
社区成员




using System.Runtime.InteropServices;
public static uint SND_ASYNC = 0x0001; // play asynchronously
public static uint SND_FILENAME = 0x00020000; // name is file name
[DllImport("winmm.dll")]
public static extern uint mciSendString(string lpstrCommand,
string lpstrReturnString, uint uReturnLength, uint hWndCallback);
private void button1_Click(object sender, EventArgs e)
{
mciSendString(@"close temp_alias", null, 0, 0);
mciSendString(@"open ""E:\音乐\周杰伦-东风破.mp3"" alias temp_alias",
null, 0, 0);
mciSendString("play temp_alias repeat", null, 0, 0);
}
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As UInteger, ByVal hWndCallback As UInteger) As Long
Const SND_ASYNC As Integer = &H1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sndPlaySound("chord", SND_ASYNC)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mciSendString("close temp_alias", Nothing, 0, 0)
mciSendString("open ""E:\音乐\周杰伦-东风破.mp3"" alias temp_alias", Nothing, 0, 0)
mciSendString("play temp_alias repeat", Nothing, 0, 0)
End Sub
void playmusic()
{
string mp3File=Application.StartupPath+"\\mp3\\你若成风.mp3";
QuartzTypeLib.FilgraphManager graphManager=new QuartzTypeLib.FilgraphManager ;
QuartzTypeLib.IMediaControl mycontrol=(QuartzTypeLib.IMediaControl)graphManager;
mycontrol.RenderFile(mp3File);
mycontrol.Run();
}