Valhalla Legends Forums Archive | Visual Basic Programming | [VB6 - Solved] Get Winamp's Current Song Title via Memory

AuthorMessageTime
PaiD
Hello

I was playing with Winamp and I recieve a pointer to where a value is that I want. How would I go about getting the value?

[code]
Public Function GetTrackName() As String
Dim hwndWinamp As Long
Dim TrackIndex As Integer, TrackPos As Long, Title As String * 256
hwndWinamp = FindWindow("Winamp v1.x", vbNullString)
'GetTrackName = SendMessage(hwndWinamp, WM_WA_IPC, 0, ByVal IPC_GETLISTLENGTH)
TrackIndex = SendMessage(hwndWinamp, WM_WA_IPC, 0, ByVal IPC_GETLISTPOS)
TrackIndex = TrackIndex + 1
TrackPos = SendMessage(hwndWinamp, WM_WA_IPC, TrackIndex, ByVal IPC_GETPLAYLISTTITLE)
CopyMemory ByVal Title, TrackPos, Len(Title)
GetTrackName = Title
End Function
[/code]
I currently use CopyMemory Here and when I try this I get '8ŻG' returned. TrackPos returns the value '4697912' which is the where the song title is located in memory. Am I reading the memory block wrong? or should I be using ReadProcessMemory and if so, How would I go about using this api?

[code]
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
[/code]
October 19, 2005, 11:40 AM
l2k-Shadow
It is quite unnecessary to use CopyMemory OR ReadProcessMemory to retrieve the current song... Use
[code]
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Public Function GetTrackName() As String
Dim strReturn As String * 256, hWnd As Long
hWnd = FindWindow("Winamp v1.x", vbNullString)
If hWnd <> 0 Then
GetWindowText hWnd, strReturn, 256
strReturn = Left$(strReturn, Instr(strReturn, vbNullChar) - 1)
End If
End Function
[/code]

That should give you a good start.. After this feel free to parse the content of strReturn to suit your needs.
October 19, 2005, 5:15 PM
Adron
I thought GetWindowText did not work if you used scrolling song titles in the title bar?
October 19, 2005, 5:35 PM
PaiD
l2k-Shadow: Yes I know of this way. But I dont wish to retrieve it that way. Like Ardon says, it wont work if they have it scrolling. Also I was looking at the sdk for winamp that that api is available but only to "in process" plugins not external apps. Also I would like to find out how to get into the memory b/c there are more api calls I could use to make it easier and show more information that is only available to 'plugins'. So any help to find this out will help.

[code]
TrackPos = SendMessage(hwndWinamp, WM_WA_IPC, TrackIndex, ByVal IPC_GETPLAYLISTTITLE)
[/code]
returns a pointer into the memory of Winamp.

Edit: Ok after looking some more on Winamp's forum I found a link that explained to me what I had to do. I was close (some what)

October 19, 2005, 6:27 PM
Quarantine
Yea, in theory you were. Just need a few things done first. Nice job.
October 19, 2005, 7:57 PM

Search