Get sound volume

Posted in Others

To get sound volume, use WaveOutGetVolume function. A sound volume is variable of DWord type.

uses mmsystem;

procedure TForm1.Button1Click(Sender: TObject);
var
  Volume: DWord;
  MyWaveOutCaps: TWaveOutCaps;
begin
  if WaveOutGetDevCaps(
    WAVE_MAPPER, 
    @MyWaveOutCaps, 
    sizeof(MyWaveOutCaps))=MMSYSERR_NOERROR then
  begin
    WaveOutGetVolume(WAVE_MAPPER, @Volume);
    Label1.Caption:=IntToStr(Volume);
  end;
end;