VB MCI Control Does Not Support PC Speaker Driver

Last reviewed: June 21, 1995
Article ID: Q84268
The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows,

  versions 2.0 and 3.0
- Microsoft Professional Toolkit for Microsoft Visual Basic programming
  system for Windows, version 1.0

SUMMARY

The MCI custom does not support playing wave (.WAV) sound files through a PC speaker driver such as SPEAKER.DRV. The MCI custom control (and the Windows Media Player application) uses the MCI sound drivers, which do not support the PC speaker. The Windows default sounds and the Sound Recorder application are the only way to play sounds through the SPEAKER.DRV PC speaker driver.

MORE INFORMATION

The MCI control manages the recording and playback of multimedia files on Media Control Interface (MCI) devices, such as audio boards, MIDI sequencers, CD-ROM drives, audio CD players, video disc players, and videotape recorders and players.

Although the MCI control will not allow you to play .WAV files through the PC speaker, you can use the OLE Client Controls provided with the Professional Edition of the Microsoft Visual Basic for Windows, or with the Microsoft Visual Basic for Windows Professional Toolkit to create and play a linked Sound Recorder object from your Visual Basic for Windows program. The following is an example of this behavior. (Note that you must have the appropriate Windows sound drivers loaded in order to run this program):

  1. Run Visual Basic for Windows, or from the File menu, choose New Project (press ALT, F, N) if Visual Basic for Windows is already running. Form1 is created by default.

  2. From the File menu, choose Add File. In the Files box, select the OLECLIEN.VBX custom control file in Visual Basic 2.0 or the MSOLE2.VBX custom control file in Visual Basic 3.0. The OLE Client tool appears in the Toolbox of the Visual Basic 2.0 product, the OLE 2.0 tool appears in the Toolbox of the Visual Basic 3.0 product.

  3. Double-click the OLE Client control on the toolbar to create an OLE Client control on your form in Visual Basic 2.0, or double-click the OLE 2.0 control on the toolbar to create an OLE control on your form in Visual Basic 3.0.

  4. Double-click the form to open the Code window, and enter the following code in the Form_Click event for Visual Basic 2.0:

    OLEClient1.Class = "SoundRec" OLEClient1.Protocol = "StdFileEditing"

       OLEClient1.SourceDoc = "C:\windows\chimes.wav"   ' Name of .WAV file.
       OLEClient1.SourceItem = "LINK"
       OLEClient1.ServerType = 0      ' Linked object.
    
       OLEClient1.Action = 1      ' Create object from source file.
       OLEClient1.Action = 7      ' Activate Sound Recorder - plays sound.
       OLEClient1.Action = 10     ' Delete the object.
    
       -or-
    
    

  5. Double-click the form to open the Code window, and enter the following code in the Form_Click event for Visual Basic 3.0:

    OLE1.Class = "SoundRec"

       OLE1.SourceDoc = "C:\windows\chimes.wav"   ' Name of .WAV file.
       OLE1.SourceItem = "LINK"
    
       OLE1.Action = 1      ' Create object from source file.
       OLE1.Action = 7      ' Activate Sound Recorder - plays sound.
       OLE1.Action = 10     ' Delete the object.
    
    

  6. Press the F5 key to run the program.

The specified .WAV file should be played each time you click the form.

For more information on SPEAKER.DRV, query on the following words in the Microsoft Knowledge Base:

   SPEAKER.DRV and WDL AND windows AND 3.10


Additional reference words: 1.00 2.00 3.00 MCI.VBX
KBCategory: kbprg
KBSubcategory: PrgCtrlsCus


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.