Microsoft KB Archive/147811

= How To Detect If Computer Has Sound Card That Plays Wave Audio =

Article ID: 147811

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q147811



SUMMARY
This article describes how to detect if a system has a sound card capable of playing back wave audio data (.WAV files).



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: #If Win32 Then

Private Declare Function waveOutGetNumDevs Lib "winmm" As Long #ElseIf Win16 Then Private Declare Function waveOutGetNumDevs Lib "mmsystem" _ As Integer #End If

  Add the following code to the Command1_Click event: Private Sub Command1_Click #If Win32 Then Dim i As Long #ElseIf Win16 Then Dim i As Integer #End If     i = waveOutGetNumDevs If i > 0 Then        ' There is at least one device. 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 lets you know if your computer plays wave audio data.

Additional query words: kbVBp400 kbVBp600 kbVBp kbdsd kbDSupport kbVBA

Keywords: kbhowto KB147811

-

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

© Microsoft Corporation. All rights reserved.