Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
是一个音乐播放器,但运行不起来 模块: Option Explicit Global musicpathplay, musicpathclose As String Global musicpathpause, musicpathrecord As String Global musicpath As String Global lll% Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrcommand As String) As Long窗体Private Sub cmdpause_Click() cmdplay.Enabled = True cmdstop.Enabled = True cmdpause.Enabled = False cmdopen.Enabled = False mciExecute (musicpathpause) End SubPrivate Sub cmdplay_Click() cmdplay.Enabled = False cmdstop.Enabled = True cmdpause.Enabled = True cmdopen.Enabled = True mciExecute (musicpathplay) End SubPrivate Sub cmdstop_Click() cmdplay.Enabled = False cmdstop.Enabled = False cmdpause.Enabled = False cmdopen.Enabled = True mciExecute (musicpathclose) End SubPrivate Sub Form_Load() cmdplay.Enabled = False cmdstop.Enabled = False cmdpause.Enabled = FalseEnd Sub Private Sub cmdopen_click() CommonDialog.ShowOpen musicpath = CommonDialog.FileName If musicpath = "" Then Exit Sub cmdplay.Enabled = True cmdopen.Enabled = False Label2.Caption = CommonDialog.FileName musicpathplay = "play" + musicpath musicpathpause = "pause" + musicpath musicpathrecord = "record" + musicpath musicpathclose = "close" + musicpathEnd SubPrivate Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)End SubPrivate Sub Label2_Click()End Sub
改成Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long后,说要取个别名。可以随便取吗?
Private Declare Function mciExecute Lib "winmm.dll" Alias "mciExecute" (ByVal lpstrCommand As String) As Long找不到入口说明你的dll没有这个接口,可能是版本问题,但是我没听说那个版本没有,你找一个工具比如win98的quickview dumpbin,execope等等查看一下你系统该文件(winmm.dll)的接口函数
mciExecute("Play C:\WINNT\Media\ir_inter.wav")
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As LongPrivate Sub Form_Load() Const sAVIFile As String = "c:\myfile.avi" 'open a new avi video mciExecute "OPEN " + sAVIFile + " TYPE AVIVIDEO ALIAS kpdvideo STYLE POPUP" 'move the display window to (100,100,320,200) mciExecute "PUT kpdvideo WINDOW AT 100 100 320 200" 'double the playback speed mciExecute "SET kpdvideo SPEED 2000" 'play the video mciExecute "PLAY kpdvideo WAIT" 'remove the video from the memory mciExecute "CLOSE kpdvideo" End Sub
模块:
Option Explicit
Global musicpathplay, musicpathclose As String
Global musicpathpause, musicpathrecord As String
Global musicpath As String
Global lll%
Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrcommand As String) As Long窗体Private Sub cmdpause_Click()
cmdplay.Enabled = True
cmdstop.Enabled = True
cmdpause.Enabled = False
cmdopen.Enabled = False
mciExecute (musicpathpause)
End SubPrivate Sub cmdplay_Click()
cmdplay.Enabled = False
cmdstop.Enabled = True
cmdpause.Enabled = True
cmdopen.Enabled = True
mciExecute (musicpathplay)
End SubPrivate Sub cmdstop_Click()
cmdplay.Enabled = False
cmdstop.Enabled = False
cmdpause.Enabled = False
cmdopen.Enabled = True
mciExecute (musicpathclose)
End SubPrivate Sub Form_Load()
cmdplay.Enabled = False
cmdstop.Enabled = False
cmdpause.Enabled = FalseEnd Sub
Private Sub cmdopen_click()
CommonDialog.ShowOpen
musicpath = CommonDialog.FileName
If musicpath = "" Then Exit Sub
cmdplay.Enabled = True
cmdopen.Enabled = False
Label2.Caption = CommonDialog.FileName
musicpathplay = "play" + musicpath
musicpathpause = "pause" + musicpath
musicpathrecord = "record" + musicpath
musicpathclose = "close" + musicpathEnd SubPrivate Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)End SubPrivate Sub Label2_Click()End Sub
'open a new avi video
mciExecute "OPEN " + sAVIFile + " TYPE AVIVIDEO ALIAS kpdvideo STYLE POPUP"
'move the display window to (100,100,320,200)
mciExecute "PUT kpdvideo WINDOW AT 100 100 320 200"
'double the playback speed
mciExecute "SET kpdvideo SPEED 2000"
'play the video
mciExecute "PLAY kpdvideo WAIT"
'remove the video from the memory
mciExecute "CLOSE kpdvideo"
End Sub