uses mmsystem;
function GetWaveVolume: DWord; var Woc: TWAVEOUTCAPS; Volume: DWord; begin result := 0; if WaveOutGetDevCaps(WAVE_MAPPER, @Woc, sizeof(Woc)) = MMSYSERR_NOERROR then if Woc.dwSupport and WAVECAPS_VOLUME = WAVECAPS_VOLUME then begin WaveOutGetVolume(WAVE_MAPPER, @Volume); Result := Volume; end; end;
procedure SetWaveVolume(const AVolume: DWord); var Woc: TWAVEOUTCAPS; begin if WaveOutGetDevCaps(WAVE_MAPPER, @Woc, sizeof(Woc)) = MMSYSERR_NOERROR then if Woc.dwSupport and WAVECAPS_VOLUME = WAVECAPS_VOLUME then WaveOutSetVolume(WAVE_MAPPER, AVolume); end;
procedure TForm1.Button1Click(Sender: TObject); begin Beep; end;
procedure TForm1.Button2Click(Sender: TObject); var LeftVolume: Word; RightVolume: Word; begin LeftVolume := StrToInt(Edit1.Text); RightVolume := StrToInt(Edit2.Text); SetWaveVolume(MakeLong(LeftVolume, RightVolume)); end;
procedure TForm1.Button3Click(Sender: TObject); begin Caption := IntToStr(GetWaveVolume); end;
|