先加一个WindowsMediaPlayer控件
然后点“外接程序”--“外接程序管理器”并启动/加载“VB6资源编辑器”
点击那个“手抓魔方”的按钮--打开自定义资源--选定你要添的音乐
关闭
然后在代码里输入代码(Form1):
Dim TempData() As Byte
TempDataPath = "c:\Program Files\flies1.mp3"
TempData = LoadResData(101, "CUSTOM")
Open TempDataPath For Binary Access Write As #1
Put #1, , TempData
Close #1
WindowsMediaPlayer1.URL = TempDataPath
可以不用控件,你在窗体上添加两个按钮,在c盘根目录下放一个名字为1.mp3的音乐文件
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mciSendString "close all", 0, 0, 0
mciSendString "open " & "C:\1.mp3", 0, 0, 0
mciSendString "play " & "C:\1.mp3", 0, 0, 0
End Sub
Private Sub Command2_Click()
'音乐停止播放
mciSendString "close all", 0, 0, 0
End Sub
更多VB代码,可参阅我的博客:http://hi.baidu.com/zgmg/blog/item/abf0b951e055052943a75b09.html
最简单的就是引用windows 自带的 md plaler控件了、
http://zhidao.baidu.com/question/174989037.html