Advertisement
4_2005-2006 Miscellaneous #163749

Get Current Winamp Song

This Function gets the current winamp song. I got tired of people iming me asking for this and me redoing it each time.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
Option Explicit<br><br>
'To Use Just Do<br>
'Call MsgBox(GetSong)<br>
'And it will popup a message box with the song.
<br><br>
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long<br>
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long<br>
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long<br>
<br>
Public Function GetSong() As String<br>
Dim WinampCaption As String<br>
Dim CaptionLength As Long<br>
Dim Winamp As Long<br>
 Winamp& = FindWindow("Winamp v1.x", vbNullString)<br>
 CaptionLength& = GetWindowTextLength(Winamp&)<br>
 WinampCaption$ = String$(CaptionLength&, 0)<br>
 Call GetWindowText(Winamp&, WinampCaption$, (CaptionLength& + 1&))<br>
 <br>
 If WinampCaption <> "" Then<br>
 GetSong = WinampCaption<br>
 Else<br>
 GetSong = "Error"<br>
 End If<br>
End Function<br>
Commenti originali (3)
Recuperato da Wayback Machine