Winapi 如何指定与mciSendString API一起使用的声卡

Winapi 如何指定与mciSendString API一起使用的声卡,winapi,vb6,audio,mcisendstring,Winapi,Vb6,Audio,Mcisendstring,我正在更新旧的VB6应用程序。回到那天,我在mciSendString命令周围编写了一个包装器,以便能够录制和播放音频。当时,计算机通常只有一张声卡 现在,许多客户都有多个声卡(通常是内置声卡和USB耳机) 我似乎找不到API来指定将哪个声卡与mciSendString一起使用。有人能给我指出正确的方向吗?请在这里查看几个源代码解决方案(Ergebnisse des Wettbewerbs/德语): 这里是我的项目的一些来源 ''' <summary> ''' Return all

我正在更新旧的VB6应用程序。回到那天,我在mciSendString命令周围编写了一个包装器,以便能够录制和播放音频。当时,计算机通常只有一张声卡

现在,许多客户都有多个声卡(通常是内置声卡和USB耳机)


我似乎找不到API来指定将哪个声卡与mciSendString一起使用。有人能给我指出正确的方向吗?

请在这里查看几个源代码解决方案(Ergebnisse des Wettbewerbs/德语):

这里是我的项目的一些来源

''' <summary>
''' Return all audio devices by names
''' </summary>
Private Function ListSoundDevices(ByRef LDev As List(Of String)) As Boolean

    Dim intItem As New Integer
    Dim intNext As New Integer
    Dim intCount As New Integer
    Dim tWIC As New WaveInCaps
    Dim Enc As System.Text.ASCIIEncoding = New System.Text.ASCIIEncoding()
    Dim res As Boolean = False

    Try
        'Throw New Exception("test")
        intCount = waveInGetNumDevs()
    Catch ex As Exception
        'no devices found
        Return False
    End Try

    If intCount <> 0 Then
        For intItem = 0 To intCount - 1
            If waveInGetDevCaps(intItem, tWIC, Marshal.SizeOf(tWIC)) = MMSYSERR_NOERROR Then
                If (tWIC.Formats And WAVE_FORMAT_4S16) = WAVE_FORMAT_4S16 Then
                    If LDev Is Nothing Then LDev = New List(Of String)
                    Dim B() As Byte = System.Text.Encoding.Default.GetBytes(tWIC.ProductName.ToString.ToCharArray)
                    LDev.Add(Enc.GetString(B, 0, B.Length))
                    intNext += 1
                End If
            End If
        Next

        If intNext > 0 Then res = True
    End If

    Return res
End Function
“”
''按名称返回所有音频设备
''' 
私有函数ListSoundDevices(ByRef LDev作为列表(字符串))作为布尔值
Dim intItem作为新整数
将intNext设置为新整数
Dim intCount作为新整数
将tWIC变暗为新的WaveInCaps
Dim Enc As System.Text.asciencoding=新建System.Text.asciencoding()
将分辨率设置为布尔值=False
尝试
'抛出新异常(“测试”)
intCount=waveInGetNumDevs()
特例
“没有找到任何设备
返回错误
结束尝试
如果int计数为0,则
对于intItem=0到intCount-1
如果waveInGetDevCaps(intItem、tWIC、Marshal.SizeOf(tWIC))=MMSYSERR\u无错误,则
如果(tWIC.Formats和WAVE_FORMAT_4S16)=WAVE_FORMAT_4S16,则
如果LDev为空,则LDev=新列表(字符串)
Dim B()的形式为Byte=System.Text.Encoding.Default.GetBytes(tWIC.ProductName.ToString.ToCharray)
LDev.Add(Enc.GetString(B,0,B.Length))
intNext+=1
如果结束
如果结束
下一个
如果intNext>0,则res=True
如果结束
返回res
端函数
使用设备ID开始录制和使用。
希望这对微软提供了帮助

要设置多媒体控件使用的WaveAudio设备(声卡),必须使用mciSendCommand API。多媒体控件不直接提供用于设置播放或录制设备的方法

Dim parms As MCI_WAVE_SET_PARMS
Dim rc As Long

' Specify the soundcard. This specifies the soundcard with a deviceID
' of 0. If you have a single soundcard, then this will open it. If you
' have multiple soundcards, the deviceIDs will be 0, 1, 2, etc.
parms.wOutput = 0

' Send the MCI command to set the output device.
rc = mciSendCommand(MMControl1.DeviceID, MCI_SET, MCI_WAVE_OUTPUT, parms)