vb 信息接收方式
我想编个程序:自动下载http://kookxiang.cn/msg.txt里的信息,然后播放指定的音乐。注意,播放过的不要再次播放!另:msg.txt内容:title=...
我想编个程序:自动下载http://kookxiang.cn/msg.txt里的信息,然后播放指定的音乐。
注意,播放过的不要再次播放!
另:msg.txt内容:
title=测试
msg=测试消息
music=test.mp3
3楼的错误太多了,麻烦改下。 展开
注意,播放过的不要再次播放!
另:msg.txt内容:
title=测试
msg=测试消息
music=test.mp3
3楼的错误太多了,麻烦改下。 展开
展开全部
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long '声明播放音乐的函数
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function '声明URLDownLoadToFile函数
'WinApi可播放Wav声音文件
Private Sub Form_Load()
DownloadFile "http://kookxiang.cn/msg.txt", App.Path & "\msg.txt"
Open App.Path & "\msg.txt" For Input As #1
Input #1, a
Input #1, b
Input #1, f
c = Split(a, "=")
d = Split(b, "=")
e = Split(f, "=")
Title = c(1)
msg = d(1)
music = e(1)
sndPlaySound App.Path & "\" & music, &H1
End Sub
修改过了,你要把欲播放的文件和程序放在同一目录。
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function '声明URLDownLoadToFile函数
'WinApi可播放Wav声音文件
Private Sub Form_Load()
DownloadFile "http://kookxiang.cn/msg.txt", App.Path & "\msg.txt"
Open App.Path & "\msg.txt" For Input As #1
Input #1, a
Input #1, b
Input #1, f
c = Split(a, "=")
d = Split(b, "=")
e = Split(f, "=")
Title = c(1)
msg = d(1)
music = e(1)
sndPlaySound App.Path & "\" & music, &H1
End Sub
修改过了,你要把欲播放的文件和程序放在同一目录。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询