Delphi XE 6 – Get currently playing title from Winamp

const   IPC_GETPLAYLISTFILE  : integer = 214;
        IPC_GETPLAYLISTTITLE : integer = 213;
        IPC_GETLISTPOS :integer = 125;

        WINAMP_BUTTON2   : integer = 40045; // play
        WINAMP_BUTTON4   : integer = 40047; // stop
        WINAMP_BUTTON5   : integer = 40048; // next title

[…]

procedure Refresh();
var
    hWinamp: THandle;
    rawString: array[0..500] of Char;
    playlistEntryPointer, hProcessId: Cardinal;
    result:string;
    uselessDummy:NativeUInt;
begin
  hWinamp:= FindWindow('Winamp v1.x',nil);
  if hWinamp<> 0 then
    begin
      playlistEntryPointer:= SendMessage(hWinamp,WM_USER,SendMessage(hWinamp,WM_USER,0 , IPC_GETLISTPOS), IPC_GETPLAYLISTFILE);

      GetWindowThreadProcessId(hWinamp, hProcessId);
      hWinamp:= OpenProcess(PROCESS_VM_READ,False,hProcessId);

      ReadProcessMemory(hWinamp, Pointer(playlistEntryPointer), @rawString, 500, uselessDummy);
      CloseHandle(hWinamp);

      result:= String(rawString)
    end;

    Edit_input.Text := result;
end;