Use the SendMessage function to send requests to Calaym

LRESULT SendMessage(
  HWND hWnd,      // handle of Calaym's messaging window
  UINT Msg,       // WM_COMMAND (273 / 111h)
  WPARAM wParam,  // Request
  LPARAM lParam   // NULL (not used), or handle to a file-mapping object for
                  // some commands
);

Parameters:
  hWnd
      The handle of Calaym's messaging window, which can be located using
      the FindWindow function
  Msg
      WM_COMMAND (273 / 111h)
  wParam
      Value specifying what to perform; This can be:
         200 Previous song                       ; returns playstate (0/1/2)
                                                 ;   (subject to change!)
         201 Play / Restart                      ; returns playstate (0/1/2)
         202 (Un)Pause                           ; returns playstate (0/1/2)
         203 Stop                                ; returns playstate (0/1/2)
         204 Skip/Next song                      ; returns playstate (0/1/2)
         205 End Song                            ; returns playstate (0/1/2)
                                                 ;   (subject to change!)
         220 Seek backward
         221 Seek forward
         222 Volume Up                           ; returns volume (0-255)
         223 Volume Down                         ; returns volume (0-255)
     230-240 Volume 0-100%                       ; returns volume (0-255)
         300 Mark previous playlist item
         301 Play playlist item next / end/skip song (Playlist doubleclick
             action)
         302 Play playlist item (skip song)
         303 Play playlist item (end song)
         304 Play playlist item next
         305 Mark next playlist item
         306 Select current (/next) playlist item
         307 Select random playlist item
         318 PageUp playlist
         319 PageDown playlist
         320 Perform autorefresh
         330 Remove autorefresh songs
         331 Remove non-autorefresh songs
         340 Delayed autorefresh
         360 Abort directory reading
      Following settings toggle (x=0), or set on (x=1)/off (x=2):
         39x MP3 Infos                           ; returns state (0/1)
         400 Toggle Repeat mode                  ; returns state (0-2)
         401 Repeat single                       ; returns state (0-2)
         402 Repeat all                          ; returns state (0-2)
         403 Repeat random                       ; returns state (0-2)
         41x Fading (Fade in/out)                ; returns state (0/1)
         42x Spectrum analyzer                   ; returns state (0/1)
         43x Remove missing songs                ; returns state (0/1)
         44x Remove manually skipped/ended songs ; returns state (0/1)
         45x Remove played songs                 ; returns state (0/1)
         460 Toggle end-song-processing
               returns End-song-processing (0-3)
         461 End-song-processing: off
               returns End-song-processing (0-3)
         462 End-song-processing: crossfade
               returns End-song-processing (0-3)
         463 End-song-processing: MiniDisk record mode
               returns End-song-processing (0-3)
         464 End-song-processing: stop after each song
               returns End-song-processing (0-3)
         465 End-song-processing: Toggle crossfade
               returns End-song-processing (0-3)
         466 End-song-processing: Toggle MiniDisk record mode
               returns End-song-processing (0-3)
         467 End-song-processing: Toggle stop after each song
               returns End-song-processing (0-3)
         48x Intro mode
         510 IR-Sleeptime off
         512 IR-Sleeptime +30min
         513 IR-Sleeptime -30min
         515 IR-Sleeptime: 30min
         516 IR-Sleeptime: 60min
         517 IR-Sleeptime: 90min
         518 IR-Sleeptime: 120min
         590 Shutdown/Hibernate/Standby immediatelly
         600 Show/Restore Calaym
         601 Hide/Minimize Calaym
         610 Show current song title

      Text-based requests:
        For text-based queries, Calaym uses file-mapping technology for
        interprocess communication. You must create a (unique?) named file-
        mapping object. As name for this object, use "calaym_" followed by
        an numeric expression (in dword range); That expression is later passed
        as lParam. E.g.: Create the filemapping:
          hMapFile = CreateFileMapping(Invalid_Handle, NULL, PAGE_READWRITE, 0,
                                       <Size>, "calaym_1234");
        and pass 1234 as lParam when sending the message;

        If your file-mapping object has insufficient space for the requested
        (NULL-terminated) string, the function fails. As the copied strings are
        unicode, you will need 2 bytes per character.

        If successfull, the length (in characters) of the string, not including
        the terminating NULL-character (or any extra data), is returned.

         800 Request current song (full filename / internet stream info)
             With version 1.00 beta 61+, the messaging window also supports
             WM_GETTEXT and WM_GETTEXTLEN, but returning the current song (full
             filename / extended internet stream info in format
               URL[<cr>Caption[|<cr>URL for recent playlist, or homepage...]]
             ) only, if not stopped/paused etc.!
             
             This request adds 6 additional bytes (!) after the terminating null
             character (2 bytes), specifying:
             (lpdata + (length + 1) * 2 + 1): operation state
             (lpdata + (length + 1) * 2 + 2): current play state
             (lpdata + (length + 1) * 2 + 3): type of music
             (lpdata + (length + 1) * 2 + 4): reserved
             (lpdata + (length + 1) * 2 + 5): the song length (4 bytes)
             If your file-mapping object has insufficient space for the
             requested (NULL-terminated) string plus this extra bytes, This
             request will fail.
             It will also fail if there is no song being playing/paused; Play/
             operation state will never be 0 (stopped) etc.
             If you don't need this extra information, just thread as a null-
             terminatedstring if successfull.

         801 Request current song
             This request is identically to request 800, except the path is
             stripped from the filename / it returns the best internet stream
             caption only.
         81x Request previous song list
             Songs will be seperated with an <CR><LF> (<13><10>) (There is no
             additional leading/trailing <CR><LF>);
             800 default list (time, filenames without path)
              +1 full filenames (including path)
              +2 suppress time
              +4 invert list

  lParam
      For text-based requests, an identifier for a named file-mapping object;
      All other requests do not need this parameter, so you should specify NULL.

Return values:
  Only specific requests have a return value, all other will simply return NULL.

Remarks:
  Older versions may not support all request, or the class name of the messaging
  window may differ.

  You can alternatively use the PostMessage function for all requests that do
  not return values or require reliable lParam data (e.g. file-mapping handles);
  Except if 'Playlist update interval (LockWindowUpdate)' is set to 'When done',
  Calaym always frequencly processes messages; There is no advantage in
  functionality when using PostMessage instead of SendMessage, but execution of
  your application will continue immediatelly.

  Some functions will return a play/operation state:
    Playstates:
       0 stopped
       1 playing
       2 paused
    Operation states:
       0 stopped
       1 playing
       2 paused
       3=starting
       4=Applying soundcard
       5=Quitting
       6=Deleting files
       7=Reading files
       8=(Cross-)fading
    Music types:
       0 None
       1 Tracker
       2 Stream
       3 CDAudio
       4 InetStream

Unicode:
  The Windows 95, 98 and ME api has limited unicode support; you may want to use
  the returned string with the following functions: ExtTextOutW, GetCharWidthW,
  GetTextExtentExPointW, GetTextExtentPoint32W, GetTextExtentPointW, lstrlenW,
  MessageBoxExW, MessageBoxW, TextOutW.
         
  Use the WideCharToMultiByte/MultiByteToWideChar functions to convert between
  Unicode and Ansi.

Example:
(Hope a willing C programmer will test & fix this up...)

  To skip (end) the current song:
  -------------------------------
    #include "headers.h"
    HANDLE hWndCalaym;

    hWndCalaym = FindWindow("CalaymInterMsgClass100", "Calaym");
    if (hWndCalaym != NULL)
    {
      SendMessage(hWndCalaym, WM_COMMAND, 205, 0);
    }

  To request the current playing song:
  ------------------------------------
    #include "headers.h"
    HANDLE hWndCalaym;
    HANDLE hMapFile;
    LPVOID lpMapAddress;
    INT RetCode;

    hWndCalaym = FindWindow("CalaymInterMsgClass100", "Calaym");
    if (hWndCalaym != NULL)
    {
      hMapFile = CreateFileMapping(Invalid_Handle, NULL, PAGE_READWRITE, 0,
                                   $204, "calaym_1234");

      if (hMapFile != NULL)
      {
        lpMapAddress = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
        if (lpMapAddress != 0)
        {
          // It is not required to map the file-mapping object before passing
          RetCode = SendMessage(hWndCalaym, WM_COMMAND, 800, 1234);
          if (RetCode != 0)
          {
            MessageBox(NULL, lpMapAddress, "Current playing song", MB_OK | MB_ICONINFORMATION);
          }
          UnmapViewOfFile(lpMapAddress);
        }
        CloseHandle(hMapFile);
      }
    }

Queries:
--------

  Use this with SendMessage to send a request;
	hwnd	the handle of CalaymInterMsgClass100 element
	uMsg	must be WM_COMMAND (273 / hex 111)
	wParam	request (id / number) as seen in the list below.
	lParam	not used (0)

  Requests:
    1   playstate
    2   operation state

CopyData:
---------

  This method is used by Calaym for passing playlists to another instance:
	hwnd	the handle of CalaymInterMsgClass100 element
	uMsg	must be WM_COPYDATA (74 / hex 44)
	wParam	not used (0)
	lParam	pointer to valid COPYDATASTRUCT

  COPYDATASTRUCT -> lpData   pointer to accessable memory
                    cbData   buffer size in bytes(!); The string will be clipped
                             on a terminating null character, otherwise the full
                             size is used.
                    dwData   request id;

  dwData:
    (0) used by previous versions;                    ansi
     1  Pass playlist/directory/URL to load (open);   unicode
     2  Pass playlist/directory to load (enqueue);    unicode
     3  Pass URL to load;                             unicode
   All other values are reserved, but are always unicode
   For URLs, you can use this syntax:
     URL[<cr>Caption[|<cr>URL for recent playlist, or homepage...]]
   if no Caption/URL is specified, Calaym uses stream information, if
   available.
   Returns 1 on success, 2 if another operation is still pending or 0 otherwise.
   The return value is no guaranty the desired action is performed because 
   Calaym copies the data only and PostMessage itself and returms to your
   application immediately, while processing the data later.

  Tip: Use WideCharToMultiByte/MultiByteToWideChar to convert between Unicode
       and Ansi.
  Hint: If you pass "test", Calaym will popup when processing the message;
        (If Calaym isn't performing any interfering actions! Result is 1)

  Versions older than 1.00 beta 63a will not handle unicode request properly on
  non-Unicode systems (Win9x/Me) due a bug.


Notes:
------

  Use at your own risk.
