找到了
这里是主要代码
type Tvolume=record
left,right:word;
end;
procedure fillstruct(control
MixerControl;var Cdetails:tMIXERCONTROLDETAILS);
function getpeak(control
MixerControl;var peak:integer):boolean;
function setvolume(control
mixercontrol;
volume:Tvolume):boolean;
function getvolume(control
mixercontrol;
volume:Tvolume):boolean;
var
Form1: TForm1;
mcontrols:array of array of array of PMixerControl;
//mixer的数组
fmixerhandle:HMIXER;
//mixer的句柄
implementation
{$R *.DFM}
procedure fillstruct(control
MixerControl;var Cdetails:tMIXERCONTROLDETAILS);
begin
Cdetails.cbStruct:=sizeof(cdetails);
cdetails.dwControlID:=Control.dwControlID;
cdetails.cbDetails:=sizeof(integer);
cdetails.hwndOwner:=0;
end;
function getpeak(control
MixerControl;var peak:integer):boolean;
var
details:TMixerControlDetailsSigned;
cdetails:tMIXERCONTROLDETAILS;
begin
Result:=false;
if control.dwControlType<> mixercontrol_controltype_peakmeter then
exit;
cdetails.cChannels:=1;
cdetails.paDetails:=@details;
fillstruct(control,cdetails);
result:=mixerGetControlDetails(fmixerhandle,@cdetails,MIXER_GETCONTROLDETAILSF_VALUE)=0;
end;
function setvolume(control
mixercontrol;
volume:Tvolume):boolean;
var
details:array[0..30] of integer;
cdetails:tMIXERCONTROLDETAILS;
begin
fillstruct(control,cdetails);
cdetails.cChannels:=2;
cdetails.paDetails:=@details;
details[0]:=volume.left;
details[1]:=volume.right;
result:=mixerSetControlDetails(fmixerhandle,@cdetails,MIXER_GETCONTROLDETAILSF_VALUE)=0;
volume.left:=details[0];
volume.right:=details[1];
end;
function getvolume(control
mixercontrol;
volume:Tvolume):boolean;
var
details:array[0..30] of integer;
cdetails:tMIXERCONTROLDETAILS;
begin
fillstruct(control,cdetails);
cdetails.cChannels:=2;
cdetails.paDetails:=@details;
result:=mixerGetControlDetails(fmixerhandle,@cdetails,MIXER_GETCONTROLDETAILSF_VALUE)=0;
volume.left:=details[0];
volume.right:=details[1];
end;