home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / win_lrn / sound / opensnd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  1.4 KB  |  52 lines

  1. /*
  2.  *  OpenSound
  3.  *
  4.  *  This program demonstrates the use of the function OpenSound.
  5.  *  This function opens access to the play device ande prevents subsequent
  6.  *  opening of the device by other applications.  This function has no
  7.  *  parameters.
  8.  *
  9.  */
  10.  
  11. #include "windows.h"
  12.  
  13. int    sprintf (PSTR, PSTR, int);
  14.  
  15. int    PASCAL WinMain (hInstance, hPrevInstance, lpszCmdLine, cmdShow)
  16. HANDLE hInstance, hPrevInstance;
  17. LPSTR lpszCmdLine;
  18. int    cmdShow;
  19. {
  20.   short    nVoices;
  21.   char    szBuffer[30];
  22.  
  23.   nVoices = OpenSound ();   /* Opens access to the play device and prevents
  24.                              * subsequent opening of the device by other
  25.                              * applications.  Return value specifies the
  26.                                    * number of voices available. */
  27.  
  28.   CloseSound ();  /* CloseSound must be invoked to allow other applications
  29.                         * to access the play device */
  30.  
  31. /* return code for OpenSound routine */
  32.   if (nVoices == S_SERDVNA)
  33.   {
  34.     MessageBox (NULL, (LPSTR)"Play device in use",
  35.         (LPSTR)"Done", MB_OK);
  36.   }
  37.   else if (nVoices == S_SEROFM)
  38.   {
  39.     MessageBox (NULL, (LPSTR)"Insufficient memory available",
  40.         (LPSTR)"Done", MB_OK);
  41.   }
  42.   else
  43.   {
  44.     sprintf (szBuffer, "%d voice (s) are available", nVoices);
  45.     MessageBox (GetFocus (), (LPSTR)szBuffer,
  46.         (LPSTR)"Done", MB_OK);
  47.   }
  48.   return 0;
  49. }
  50.  
  51.  
  52.