获取系统的音频输出设备并添加到一个组合框中

本文介绍了一段C++代码,该代码使用Windows API函数waveInGetNumDevs和waveInGetDevCaps来枚举系统中可用的音频输入设备,并将设备名称添加到组合框中供用户选择。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

     //************************ init the waveIn Device List ****************

      int n=waveInGetNumDevs();
   int i;
   CString str;
   WAVEINCAPS tmpWAVEINCAPS;

   for(i=0;i<n;i++)
   {
  waveInGetDevCaps(i,&tmpWAVEINCAPS,sizeof(tmpWAVEINCAPS));
  str=tmpWAVEINCAPS.szPname;
  m_DeviceList.AddString(str);
   }
  
   m_DeviceList.SetCurSel(0);
      m_comb_channels.SetCurSel(1);
   m_comb_sampleLength.SetCurSel(1);
 //*********************************************************************



测试,这段代码完整的应该为:

#include <mmsystem.h> 
#pragma comment(lib,"winmm") 

添加组合框控件:IDIDC_COMBO_DEVICELIST,绑定控制成员变量:m_DeviceList

BOOL CAudioDeviceEnumDlg::OnInitDialog()
{


//************************ init the waveIn Device List ****************

int n=waveInGetNumDevs();
int i;
CString str;
WAVEINCAPS tmpWAVEINCAPS;

for(i=0;i<n;i++)
{
waveInGetDevCaps(i,&tmpWAVEINCAPS,sizeof(tmpWAVEINCAPS));
str=tmpWAVEINCAPS.szPname;
m_DeviceList.AddString(str);
}

m_DeviceList.SetCurSel(0);
// m_comb_channels.SetCurSel(1);
// m_comb_sampleLength.SetCurSel(1);
//*********************************************************************
return TRUE;  // return TRUE  unless you set the focus to a control
}

这样子就会显示出来,其中的两行应该是其它的内容。


获取系统的音频输出设备并添加到一个组合框中 - 加菲 - 视频会议 - 加菲
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值