Tag Archives: Output

How to check if a computer has a playback or input Soundcard in VB and VB.NET

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
 

Thankfully, Microsoft has a couple simple little API calls that will determine how many playback devices the target computer has and how many audio input devices for recording. The API calls are listed below…


Visual Basic.NET, Visual Basic 2008, VB 2010, VB 2013

   Private Declare Function waveOutGetNumDevs Lib "winmm.dll" Alias "waveOutGetNumDevs" () As Int32

    Private Declare Function waveInGetNumDevs Lib "winmm.dll" Alias "waveInGetNumDevs" () As Int32

Then you simply need to call those 2 functions and check what the retturn value. The return value will be how many devices on the target computer with playback and input capabilities. And if it happens to return a 0, then the computer does not have any…

        Dim audioPlaybackDevices As Int32

        Dim audioInputDevices As Int32

        audioInputDevices = waveInGetNumDevs

        audioPlaybackDevices = waveOutGetNumDevs

        MsgBox("This computer has: " & audioPlaybackDevices.ToString & " playback devices")

        MsgBox("This computer also has: " & audioInputDevices.ToString & " recording devices")

Visual Basic 6.0

VB 6.0 uses the same functions as .NET but with Long types instead of Integer.

    Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long

    Private Declare Function waveInGetNumDevs Lib "winmm.dll" () As Long

 


        Dim audioPlaybackDevices As Long

        Dim audioInputDevices As Long

        audioInputDevices = waveInGetNumDevs

        audioPlaybackDevices = waveOutGetNumDevs

        MsgBox("This computer has: " & audioPlaybackDevices & " playback devices")

        MsgBox("This computer also has: " & audioInputDevices & " recording devices")


That’s all there is to it for VB Classic and for Visual Basic.NET.     🙂

Jason

Minor Revision: 2015