VB语言

本类阅读TOP10

·Visual Basic 安装程序的制作!!
·VB中使用EXCEL输出
·一个简单的MP3播放器
·VB程序实现WindowsXP效果的界面!!
·VB打造超酷个性化菜单(六)
·透明位图
·平铺与拉伸MDI窗口的背景图 ~!~
·对《VB程序实现WindowsXP效果的界面》一文的补遗
·从Windows资源管理器中拖动文件
·VB打造超酷个性化菜单(一)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
如 何 用 API 播 放 CD

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

'Author: Gordon F. MacLeod
' How to play a CD Audio disc via API

' Declare the following API
Declare Function mciSendString& Lib "MMSYSTEM" (ByVal lpstrCommand$,ByVal lpstrReturnStr As Any, ByVal wReturnLen%, ByVal hCallBack%)

'Add the code below to appropriate routines

Sub cmdPlay_Click ()
  Dim lRet As Long
  Dim nCurrentTrack As Integer

  'Open the device
  lRet = 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 beginning
  lRet = mciSendString("play cd", 0&, 0, 0)

  'Or to play from a specific track, say track 4
  nCurrentTrack = 4
  lRet = mciSendString("play cd from" & Str(nCurrentTrack), 0&, 0, 0)

End Sub
 

' Remember to Close the device when ending playback

Sub cmdStop_Click ()
  Dim lRet As Long

  'Stop the playback
 
lRet = mciSendString("stop cd wait", 0&, 0, 0)

  DoEvents  'Let Windows process the event

  'Close the device
 
lRet = mciSendString("close cd", 0&, 0, 0)

End Sub

 




相关文章

相关软件