Declare Function mciSendString& Lib "MMSYSTEM" (ByVal lpstrCommand$, ByVal lpstrReturnStr As Any, ByVal wReturnLen%, ByVal hCallBack%)'Add the code below to appropriate routinesSub cmdPlay_Click ()Dim lRet As LongDim nCurrentTrack As Integer'Open the devicelRet = mciSendString("open cdaudio alias cd wait", 0&, 0, 0)'Set the time format to Tracks (default is milliseconds)lRet = mciSendString("set cd time format tmsf", 0&, 0, 0)'Then to play from the beginninglRet = mciSendString("play cd", 0&, 0, 0)'Or to play from a specific track, say track 4nCurrentTrack = 4lRet = mciSendString("play cd from" & Str(nCurrentTrack), 0&, 0, 0)End Sub' Remember to Close the device when ending playbackSub cmdStop_Click ()Dim lRet As Long'Stop the playbacklRet = mciSendString("stop cd wait", 0&, 0, 0)DoEvents 'Let Windows process the event'Close the devicelRet = mciSendString("close cd", 0&, 0, 0)End Sub---------------------------------------------------

评论