我想运行一个wma或mp3文件,用什么API函数调用?
谢谢,
在线等待!!!!!!

解决方案 »

  1.   

    用什么api函数不知道
    网上能找到很多运行mp3的控件
      

  2.   

    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA"(Byval lpstrCommand As String,ByVal lpstrRetumString As String,ByVal uReturnLength As long,ByVal hwndCallback as long) As longhttp://www.itspzo.com/bbs/dispbbs.asp?boardid=6&id=289&page=1
      

  3.   

    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用法:
    先要打开:
    mciSendString "open " & strTarget, vbNullString, 0, 0
    开始播放:
    mciSendString "play " & strTarget, vbNullString, 0, 0
    暂停:
    mciSendString "pause " & strTarget, vbNullString, 0, 0
    关闭:就是停止:
    mciSendString "close " & strTarget, vbNullString, 0, 0strTarget是mp3文件的全路径,而且要求是短文件名
    获取短文件名的api:
    Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
    用法:
    '得到短文件名
    比如:strNewTarget="c:\123\123456785634525.mp3"
    strShortPathName = String(LenB(strNewTarget), Chr(0))
    GetShortPathName strNewTarget, strShortPathName, Len(strShortPathName)
    strShortPathName = Left(strShortPathName, InStr(strShortPathName, Chr(0)) - 1)
    完了后strShortPathName ="c:\123\123456~1.mp3"
      

  4.   

    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 Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As LongPrivate Sub Command1_Click()
        strTarget = "d:\a.mp3"
        
        strShortPathName = String(LenB(strTarget), Chr(0))
        GetShortPathName strNewTarget, strShortPathName, Len(strShortPathName)
        strShortPathName = Left(strShortPathName, InStr(strShortPathName, Chr(0)) - 1)    mciSendString "open " & strShortPathName, vbNullString, 0, 0
        mciSendString "play " & strShortPathName, vbNullString, 0, 0End Sub
      

  5.   

    Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Public Const SND_SYNC = &H0
    Public Const SND_ASYNC = &H1
    Public Const SND_NODEFAULT = &H2
    Public Const SND_LOOP = &H8
    Public Const SND_NOSTOP = &H10sndPlaySound App.Path & "\abc.WAV", SND_ASYNC Or SND_NODEFAULT
      

  6.   

    sndPlaySound "d:\a.wma", SND_ASYNC Or SND_NODEFAULT
    为什么这个播不出来呢?
      

  7.   

    可以去我的网站上查询:http://j2soft.008.net/
    VB资料->查询媒体播放器即可