ich habe auf dieser Site einen Code von Nepumuk v. 18.01.2005 gefundern, der es erlaubt über den Windows Media Player Musik zu spielen - und das Programm im Hintergrund beläßt.
Zur Lauffähigkeit muß ein Verweis gesetzt werden.
Bei Codeausführung kommt der Laufzeitfehler 80004005 (Automatisierungsfehler; unbekannter Fehler).
Ich wäre für Hilfe dankbar, diesen Fehler zu beheben.
Hier noch der Code, den ich vollständig in ein Standardmodul kopiert habe.
Beste Grüße
Thomas Gestrich
CODE:
Option Explicit
Private Const SW_MINIMIZE = 6
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function ClientToScreen Lib "user32" _
(ByVal hwnd As Long, _
lpPoint As POINTAPI) As Long
Private Declare Function GetWindowPlacement Lib "user32" _
(ByVal hwnd As Long, _
lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function SetWindowPlacement Lib "user32" _
(ByVal hwnd As Long, _
lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Public Sub play()
Dim Player As WindowsMediaPlayer
Set Player = New WindowsMediaPlayer 'HIER ENTSTEHT FEHLER
Player.openPlayer ("D:\ ... \blabla.mp3")
Set Player = Nothing
Sleep 100 'Wartezeit in Millisekunden eventuell erhöhen!!
unvisible
End Sub
Private Sub unvisible()
Dim WinEst As WINDOWPLACEMENT
Dim Punto As POINTAPI
Dim rtn As Long
WinEst.Length = Len(WinEst)
rtn = GetWindowPlacement(FindWindow(vbNullString, "Windows Media Player"), WinEst)
If rtn 0 Then
Punto.x = 100
Punto.y = 100
WinEst.showCmd = SW_MINIMIZE
WinEst.ptMinPosition = Punto
WinEst.ptMaxPosition = Punto
SetWindowPlacement FindWindow(vbNullString, "Windows Media Player"), WinEst
End If
End Sub