google eyes
07-01-2006, 04:00 PM
How would I go about getting the current song playing with Windows Media Player, or even Winamp. Right now, I'm doing it a very messy way, and this way only works with Winamp. To get the current song playing for Winamp, I just get Winamp's tittle, and it gives me the current song. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Form_Load() Dim hwnd As Long Dim GetTitle As Long Dim Title As String Title = Space$(255) hwnd = FindWindow("winamp v1.x", vbNullString) 'find the winamp window If hwnd > 0 Then 'if we find the winamp window GetTile = GetWindowText(hwnd, Title, 255) 'Get the title of the winamp window and put it in "Title" MsgBox Title End If End Sub There HAS to be a more efficient way, hasn't there? Plus, I know they're a way to get the current song playing in Windows Media Player. Any suggestions? Thank you. |