在sohu用VB作关键字搜索一下吧

解决方案 »

  1.   

    'InModule1
    Option ExplicitDeclare 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
    Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
    'In form
    Option ExplicitPrivate Sub Command1_Click()
        Dim PathName As String, S As String, ShortPathName As String
        
        PathName = File1.Path
        If Right(PathName, 1) <> "\" Then PathName = PathName & "\"
        PathName = PathName & File1.FileName
        
        S = String(LenB(PathName), Chr(0))
        GetShortPathName PathName, S, Len(S)
        ShortPathName = Left(S, InStr(S, Chr(0)) - 1)    mciSendString "close MyWav", vbNullString, 0, 0
        mciSendString "open " & ShortPathName & " alias MyWav", vbNullString, 0, 0
        mciSendString "play MyWav", vbNullString, 0, 0
    End SubPrivate Sub Command2_Click()
        mciSendString "close MyWav", vbNullString, 0, 0
    End SubPrivate Sub Dir1_Change()
        File1.Path = Dir1.Path
    End SubPrivate Sub Drive1_Change()
        Dir1.Path = Drive1.Drive
    End SubPrivate Sub Form_Unload(Cancel As Integer)
        mciSendString "close MyWav", vbNullString, 0, 0
    End Sub