AW: einbinden von datein
13.11.2006 12:09:11
datein
' Modul MP3-Play and Stop via API
'Quelle: http://www.vbarchiv.net/archiv/tipp_499.html
Option Explicit
' zunächst die benötigte API-Deklaration
Private Declare
Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" (ByVal lpszCommand As String, _
ByVal lpszReturnString As String, _
ByVal cchReturnLength 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 Long
' MP3-Datei abspielen
Public
Function MP3_Play(ByVal sFile As String, _
ByVal sAlias As String) As Boolean
Dim bResult As Boolean
' Dateinamen in DOS 8.3 Format, da z.B. Sonderzeichen
' wie Leerzeichen Probleme machen
Dim sBuffer As String
Dim lResult As Long
sBuffer = Space$(255)
lResult = 2
If lResult <> 0 Then
sFile = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
' MCI öffnen
lResult = mciSendString("open " & sFile & _
" type MPEGVideo alias " & sAlias, 0, 0, 0)
If lResult = 0 Then
' MP3 abspielen
If mciSendString("play " & sAlias & _
" from 0", 0, 0, 0) = 0 Then
bResult = True
End If
End If
End If
MP3_Play = bResult
End Function
' Wiedergabe stoppen und MCI schließen
Public
Sub MP3_Stop(ByVal sAlias As String)
mciSendString "stop " & sAlias, 0, 0, 0
mciSendString "close " & sAlias, 0, 0, 0
End Sub
zeile 14:
sFile = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
was is instr!? weißt du das!?