private { Private declarations } public { Public declarations } end;
var Form1: TForm1; i:integer; implementation
{$R *.DFM}
function GetMasterVolumeControl( Mixer: hMixerObj; var Control: TMixerControl): MMResult; {Returns True on success} var Line: TMixerLine; Controls: TMixerLineControls; begin ZeroMemory(@Line, SizeOf(Line)); Line.cbStruct := SizeOf(Line); Line.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; Result := mixerGetLineInfo(Mixer, @Line, MIXER_GETLINEINFOF_COMPONENTTYPE); if Result = MMSYSERR_NOERROR then begin ZeroMemory(@Controls, SizeOf(Controls)); Controls.cbStruct := SizeOf(Controls); Controls.dwLineID := Line.dwLineID; Controls.cControls := 1; Controls.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME; Controls.cbmxctrl := SizeOf(Control); Controls.pamxctrl := @Control; Result := mixerGetLineControls(Mixer, @Controls, MIXER_GETLINECONTROLSF_ONEBYTYPE); end; end;
procedure SetMasterVolume(Mixer: hMixerObj; Value: Word); var MasterVolume: TMixerControl; Details: TMixerControlDetails; UnsignedDetails: TMixerControlDetailsUnsigned; Code: MMResult; begin Code := GetMasterVolumeControl(Mixer, MasterVolume); if Code = MMSYSERR_NOERROR then begin with Details do begin cbStruct := SizeOf(Details); dwControlID := MasterVolume.dwControlID; cChannels := 1; {set all channels} cMultipleItems := 0; cbDetails := SizeOf(UnsignedDetails); paDetails := @UnsignedDetails; end; UnsignedDetails.dwValue := Value; Code := mixerSetControlDetails(Mixer, @Details, MIXER_SETCONTROLDETAILSF_VALUE); end; if Code <> MMSYSERR_NOERROR then raise Exception.CreateFmt(\'SetMasterVolume failure, \' + \'multimedia system error #%d\', [Code]); end;
procedure TForm1.Button2Click(Sender: TObject); begin I:=I+1000; setmastervolume(0,I); end;
procedure TForm1.Button1Click(Sender: TObject); begin I:=I-1000; setmastervolume(0,I); end;
begin I:= 0; end.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.