Einzelnen Beitrag anzeigen

chest3rs

Registriert seit: 15. Okt 2006
Ort: Berlin
84 Beiträge
 
Delphi 7 Personal
 
#3

Re: Systemlautstärke verändern + Mute deaktivieren

  Alt 22. Jan 2008, 09:24
Hallo Zacherl,

Delphi-Quellcode:
uses
  MMSystem;

procedure SetVolumeMute(Enabled: Boolean);
var
  hMix : HMIXER;
  mxlc : MIXERLINECONTROLS;
  mxcd : TMIXERCONTROLDETAILS;
  mcdb : MIXERCONTROLDETAILS_BOOLEAN;
  mxc : MIXERCONTROL;
  mxl : TMIXERLINE;
  intRet, nMixerDevs : Integer;
begin
  nMixerDevs := mixerGetNumDevs();
  if (nMixerDevs < 1) then Exit;
  intRet := mixerOpen(@hMix,0,0,0,0);
  if (intRet = MMSYSERR_NOERROR) then
  begin
    mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
    mxl.cbStruct := SizeOf(mxl);
    intRet := mixerGetLineInfo(hMix, @mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);
    if (intRet = MMSYSERR_NOERROR) then
    begin
      FillChar(mxlc, SizeOf(mxlc),0);
      mxlc.cbStruct := SizeOf(mxlc);
      mxlc.dwLineID := mxl.dwLineID;
      mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_MUTE;
      mxlc.cControls := 1;
      mxlc.cbmxctrl := SizeOf(mxc);
      mxlc.pamxctrl := @mxc;
      intRet := mixerGetLineControls(hMix, @mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
      if (intRet = MMSYSERR_NOERROR) then
      begin
        FillChar(mxcd, SizeOf(mxcd),0);
        mxcd.cbStruct := SizeOf(TMIXERCONTROLDETAILS);
        mxcd.dwControlID := mxc.dwControlID;
        mxcd.cChannels := 1;
        mxcd.cbDetails := SizeOf(MIXERCONTROLDETAILS_BOOLEAN);
        mxcd.paDetails := @mcdb;
        mcdb.fValue := Ord(Enabled);
        intRet := mixerSetControlDetails(hMix, @mxcd, MIXER_SETCONTROLDETAILSF_VALUE);
        if (intRet <> MMSYSERR_NOERROR) then ShowMessage('SetControlDetails Error');
      end else ShowMessage('GetLineInfo Error');
    end;
    intRet := mixerClose(hMix);
  end;
end;
  Mit Zitat antworten Zitat