R1DLL 0.4
=========
R1DLL is a DLL for the mIRC internet relay chat client. Its main purpose is to interface with winamp
to return information about the current track and return it to mIRC. To access a specific function, you
use $dll(r1dll.dll, FunctionName, 0) in an alias or remote. To install the DLL just drop it in your
mIRC folder alongside mirc.exe. Note this is an unsupported DLL, if you're too stupid to get it working
then you probably shouldn't be using it.

Version 0.4 supports full title reporting from the foobar2000 audio player when used in conjunction
with my "foo_winamp_spam" component, availabe on the r1dll page: http://www.r1ch.net/stuff/r1dll/

Valid audio player status functions:
GetCurrentWinampSong
GetCurrentWinampSongKbps
GetCurrentWinampSongKHz
GetCurrentWinampSongFileName *
GetCurrentWinampSongChannels
GetCurrentWinampSongTotalTime
GetCurrentWinampSongElapsedTime

Valid misc functions:
GetCurrentApplication
IsWorkstationLocked

Should be pretty obvious what they do. Note, output is returned raw from winamp so you'll need to use
a little bit of mirc script to parse it nicely. The following is an example alias you can use, just
copy and paste it into your 'Aliases' section then try /spam to report to the current channel.

/spam {

  set %title $dll(r1dll.dll, GetCurrentWinampSong, 0)
  if (%title == 0) {
    /echo $active *** No supported audio player found!
    return
  }

  set %kbps $dll(r1dll.dll, GetCurrentWinampSongKbps, 0)
  set %khz $dll(r1dll.dll, GetCurrentWinampSongKHz, 0)
  set %totaltime $dll(r1dll.dll, GetCurrentWinampSongTotalTime, 0)
  set %elapsedtime $dll(r1dll.dll, GetCurrentWinampSongElapsedTime, 0)
  set %channels $dll(r1dll.dll, GetCurrentWinampSongChannels, 0)
  set %filename $dll(r1dll.dll, GetCurrentWinampSongFileName, 0)

  set %t_mins 0
  set %e_mins 0

  set %t_secs %totaltime
  if (%totaltime == -1) {
    set %fileformat %filename
    goto totalloop
  }

  set %filesize 0

  if (%filename != $null) {
    set %filesize $file(%filename).size
    set %filesize $round($calc(%filesize / 1024 / 1024),2)
    set %fileformat $upper($gettok(%filename,-1, 46))
  }

  :totalloop
  if (%t_secs < 60) {
    goto endtotalloop
  }
  inc %t_mins
  dec %t_secs 60
  goto totalloop
  :endtotalloop

  set %e_secs %elapsedtime
  :elapsedloop
  if (%e_secs < 60) {
    goto endelapsedloop
  }
  inc %e_mins
  dec %e_secs 60
  goto elapsedloop
  :endelapsedloop

  if (%t_secs < 10) {
    set %filler2 0
  }
  if (%e_secs < 10) {
    set %filler 0
  }
  if (%t_secs <= 0) {
    set %total_string 
    if (%fileformat == $null) {
      set %file_string Streaming@ $+ %kbps $+ kbps
      goto ihatemircselse
    }
    if (%kbps == 0) {
      set %file_string Streaming: %filename
      goto ihatemircselse
    }
    set %file_string Streaming: %fileformat @ $+ %kbps $+ kbps
    :ihatemircselse
    goto noset
  }

  set %total_string / $+ %t_mins $+ : $+ %filler2 $+ %t_secs
  if (%filesize != 0) {
    set %file_string %fileformat $+ @ $+ %kbps $+ kbps, %filesize $+ mb
    goto noset
  }
  set %file_string %fileformat $+ @ $+ %kbps $+ kbps
  :noset
  if (%foobar == 1) {
    /describe $active is playing %title [foobar2k]
    goto duns
  }
  /describe $active is playing %title ( $+ %file_string $+ , %e_mins $+ : $+ %filler $+ %e_secs $+ %total_string $+ )
  :duns
  unset %filesize
  unset %file_string
  unset %total_string
  unset %filename
  unset %fileformat
  unset %filler2
  unset %filler
  unset %e_mins
  unset %e_secs
  unset %title
  unset %kbps
  unset %khz
  unset %t_mins
  unset %t_secs
  unset %elapsedtime
  unset %totaltime
  unset %channels
}



* GetCurrentWinampSongFileName doesn't use the 'normal' WM_USER method of returning the song name
because for some stupid reason winamp doesn't supply it. Instead it will open the winamp process
and read out memory. This won't work if for some reason you can't open another process for memory
reading, perhaps on old Win9X versions. Thanks to QID|YDL for providing nicer code to find the base
address of the winamp filename in memory.