获取系统的音频输出设备并添加到一个组合框中
//************************ 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
}
这样子就会显示出来,其中的两行应该是其它的内容。