//列出可用的音视频设备
PROCEDURE TfrmAVset.EnumAudioDevices();
var
vt: OleVariant;
I:integer;
myinifile:tinifile;
TEMPADINDEV:INTEGER;
TEMPADOUTDEV:INTEGER;
TEMPVDCAPDEV:INTEGER;
begin
TRY
myinifile:=tinifile.Create(ExtractFilePath(Application.ExeName)+'config.ini');
TEMPADINDEV:=myinifile.READInteger('AVCHAT','ADINDEVNO',-2);
TEMPADOUTDEV:=myinifile.READINTEGER('AVCHAT','ADOUTDEVNO',-2);
TEMPVDCAPDEV:=MYINIFILE.READInteger('AVCHAT','VDINDEVNO',-2);
VOCINPUTDEVNO:=-2;
//-2表示设备为NOTHING,停止工作
//取得音频输入设备名称到一个CONNECTION
VBACollection1.ConnectTo(_Collection(AudCap1.Devices));
//在COMBOX中列出所有音频输入设备名称
FOR I:=1 TO vbacollection1.Countdo
begin
vt := Variant(i);
VOCINPUTDEV.Items.Add(VBACollection1.Item(vt));
end;
//设定默认的音频输入设备名称
IF VOCINPUTDEV.Items.COUNT>0 then
begin
IF (TEMPADINDEV>=0) AND (TEMPADINDEV<VOCINPUTDEV.Items.Count) then
begin
VOCINPUTDEV.ItemIndex:=TEMPADINDEV;
VOCINPUTDEVNO:=TEMPADINDEV;
end;
end;
VOCOUTPUTDEVNO:=-2;
//-2表示设备为NOTHING,停止工作
//取得音频输出设备名称到一个CONNECTION
VBACOLLECTION1.ConnectTo(_COLLECTION(AUDRND1.Devices));
//在COMBOX中列出所有音频输出设备名称
FOR I:=1 TO vbacollection1.Countdo
begin
vt := Variant(i);
VOCoutPUTDEV.Items.Add(VBACollection1.Item(vt));
end;
//设定默认的音频输出设备名称
IF VOCOUTPUTDEV.Items.COUNT>0 then
begin
IF (TEMPADOUTDEV>=0) AND (TEMPADOUTDEV<VOCOUTPUTDEV.Items.Count) then
begin
VOCOUTPUTDEV.ItemIndex:=TEMPADOUTDEV;
VOCOUTPUTDEVNO:=TEMPADOUTDEV;
end;
end;
VIDEOCAPDEVNO:=-2;
//取得视频输入设备名称到一个CONNECTION
VBACOLLECTION1.ConnectTo(_COLLECTION(VIDCAP1.Devices));
//在COMBOX中列出所有音频输出设备名称
FOR I:=1 TO vbacollection1.Countdo
begin
vt := Variant(i);
VIDINPUTDEV.Items.Add(VBACollection1.Item(vt));
end;
//设定默认的视频输入设备名称
IF VIDINPUTDEV.Items.COUNT>0 then
begin
IF (TEMPVDCAPDEV>=0) AND (TEMPVDCAPDEV<VIDINPUTDEV.Items.Count) then
begin
VIDINPUTDEV.ItemIndex:=TEMPVDCAPDEV;
VIDEOCAPDEVNO:=TEMPVDCAPDEV;
end;
end;
EXCEPT
ON E:EXCEPTIONdo
begin
SHOWERROR('gantandiag',e.Message);
end;
end;
end;
//----------------