Microsoft KB Archive/123974

= VB3 How to Detect If Your Computer Has a Sound Card =

Article ID: 123974

Article Last Modified on 12/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q123974



SUMMARY
It is often useful to be able to detect if a system has a sound card capable of playing back wave audio data (.WAV files). This article demonstrates how to do this.



MORE INFORMATION
The multimedia Application Programming Interface (API) has a function, waveOutGetNumDevs, which returns the number of devices in the system capable of playing back wave audio data.

Step by Step Example
 Start a new project in Visual Basic (ALT, F, N), and place a Command' button (Command1) on Form1.  Add the following declaration to the General Declarations section of Form1: Declare Function waveOutGetNumDevs Lib "MMSYSTEM" As Integer   Add the following code to the Command1_Click event: Sub Command1_Click Dim i As Integer

i = waveOutGetNumDevs If i > 0 Then        ' There is at least one. MsgBox "You Can Play Wave Data" Else MsgBox "Cannot Play Wave Data" End If  End Sub  Press the F5 key to run the code. Then click the command button. An appropriate message will let you know if your computer play wave audio data.

Additional query words: kbsound 2.00 3.00 vb3only

Keywords: KB123974

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.