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!)
         209 Query play state                    ; returns playstate (0/1/2)
         220 Seek backward
         221 Seek forward
         222 Volume: up                          ; returns volume (0-255)
         223 Volume: down                        ; returns volume (0-255)
         224 Volume: query state                 ; returns volume (0-255)
         230 Volume:   0%                        ; returns volume (0-255)
         231 Volume:  10%                        ; returns volume (0-255)
         232 Volume:  20%                        ; returns volume (0-255)
         233 Volume:  30%                        ; returns volume (0-255)
         234 Volume:  40%                        ; returns volume (0-255)
         235 Volume:  50%                        ; returns volume (0-255)
         236 Volume:  60%                        ; returns volume (0-255)
         237 Volume:  70%                        ; returns volume (0-255)
         238 Volume:  80%                        ; returns volume (0-255)
         239 Volume:  90%                        ; returns volume (0-255)
         240 Volume: 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 Page up playlist
         319 Page down playlist
         320 Perform autorefresh
         330 Remove autorefresh songs
         331 Remove non-autorefresh songs
         340 Delayed autorefresh
         360 Abort directory reading
         390 MP3 Infos: toggle                   ; returns state (0/1)
         391 MP3 Infos: on                       ; returns state (0/1)
         392 MP3 Infos: off                      ; returns state (0/1)
         393 MP3 Infos: query state              ; returns state (0/1)
         400 Repeat mode: toggle                 ; returns repeatstate (0/1/2)
         401 Repeat mode: single repeat          ; returns repeatstate (0/1/2)
         402 Repeat mode: repeat all             ; returns repeatstate (0/1/2)
         403 Repeat mode: random                 ; returns repeatstate (0/1/2)
         404 Repeat mode: query state            ; returns repeatstate (0/1/2)
         410 Fading (Fade in/out): toggle        ; returns state (0/1)
         411 Fading (Fade in/out): on            ; returns state (0/1)
         412 Fading (Fade in/out): off           ; returns state (0/1)
         413 Fading (Fade in/out): query state   ; returns state (0/1)
         420 Spectrum analyzer: toggle           ; returns state (0/1)
         421 Spectrum analyzer: on               ; returns state (0/1)
         422 Spectrum analyzer: off              ; returns state (0/1)
         423 Spectrum analyzer: query state      ; returns state (0/1)
         430 Remove missing songs: toggle        ; returns state (0/1)
         431 Remove missing songs: on            ; returns state (0/1)
         432 Remove missing songs: off           ; returns state (0/1)
         433 Remove missing songs: query state   ; returns state (0/1)
         440 Remove manually skipped/ended songs: toggle;
             returns state (0/1)
         441 Remove manually skipped/ended songs: on;
             returns state (0/1)
         442 Remove manually skipped/ended songs: off;
             returns state (0/1)
         443 Remove manually skipped/ended songs: query state;
             returns state (0/1)
         450 Remove played songs: toggle         ; returns state (0/1)
         451 Remove played songs: on             ; returns state (0/1)
         452 Remove played songs: off            ; returns state (0/1)
         453 Remove played songs: query state    ; returns state (0/1)
         460 End-song-processing: Toggle;
               returns End-song-processing (0-3)
         461 End-song-processing: off (continous playback);
               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)
         468 End-song-processing: query state;
               returns End-song-processing (0-3)
         480 Intro mode: toggle                  ; returns state (0/1)
         481 Intro mode: on                      ; returns state (0/1)
         482 Intro mode: off                     ; returns state (0/1)
         483 Intro mode: query state             ; returns state (0/1)
         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)
             This request adds 10 additional bytes (5 chars !) after the
             terminating null character (2 bytes), specifying:
             (lpdata + (length + 1) * 2 + 0): type of music
             (lpdata + (length + 1) * 2 + 1): Delay >> 4
             (lpdata + (length + 1) * 2 + 2): the song position (4 bytes)
             (lpdata + (length + 1) * 2 + 6): the song length (4 bytes)
             
             On success, it returns non-zero, where the result means:
               0x70000000: volume (0-7)
               0x0C000000: repeatstate
               0x03000000: playstate
               0x00ff0000: operationstate
               0x0000ffff: length of text (may be 0)
             If your file-mapping object has insufficient space for the
             requested (NULL-terminated) string plus this extra bytes, the
             request will fail.
             If you don't need this extra information, just thread as a null-
             terminated string if successfull, but note this might be an empty
             string.
         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.
         802 Request current song
             This request is identically to request 800, except it returns the
             best internet stream caption only.
         804 Request loudest song filename;
             Like request 800, but for loudest song
         805 Request loudest song
             This request is identically to request 804, except the path is
             stripped from the filename / it returns the best internet stream
             caption only; Internet stream captions are only updated for the
             current song.
         806 Request current song
             This request is identically to request 804, except 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
             On success, the length of the string (in characters, not including
             the null character) is returned.

  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
    Repeatstates
       0 single
       1 all
       2 random
    Operation states:
       0 stopped
       1 playing
       2 paused
       3 starting
       4 applying soundcard
       5 quitting
       6 deleting files
       7 reading files
       8 crossfading
       9 too many songs
      10 loading song
      11 loading internet stream
      12 waiting for device removal
    Music types:
       0 None
       1 Sequenced
       2 Streamed
       3 CD audio
       4 Internet stream

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("CalaymInterMsgClass101", "Calaym");
    if (hWndCalaym)
    {
      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("CalaymInterMsgClass101", "Calaym");
    if (hWndCalaym)
    {
      hMapFile = CreateFileMapping(Invalid_Handle, NULL, PAGE_READWRITE, 0,
                                   $204, "calaym_1234");

      if (hMapFile)
      {
        lpMapAddress = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
        if (lpMapAddress)
        {
          // It is not required to map the file-mapping object before passing
          RetCode = SendMessageW(hWndCalaym, WM_COMMAND, 800, 1234);
          if (RetCode)
          {
            MessageBoxW(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 CalaymInterMsgClass101 element
	uMsg	must be WM_COMMAND (273 / 0x111)
	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 CalaymInterMsgClass101 element
	uMsg	must be WM_COPYDATA (74 / 0x44)
	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 lpData
    (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 returns 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.
