如何在delphi实现电脑静音和取消静音(50)

  • 主题发起人 主题发起人 lcb139
  • 开始时间 开始时间
L

lcb139

Unregistered / Unconfirmed
GUEST, unregistred user!
如何在delphi实现电脑静音和取消静音?请知道的大侠帮帮忙.
 
uses mmsystem; function GetMasterMute( 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_MUTE; Controls.cbmxctrl := SizeOf(Control); Controls.pamxctrl := @Control; Result := mixerGetLineControls(Mixer, @Controls, MIXER_GETLINECONTROLSF_ONEBYTYPE); end; end; procedure SetMasterMuteValue( Mixer: hMixerObj; Value: Boolean); var MasterMute: TMixerControl; Details: TMixerControlDetails; BoolDetails: TMixerControlDetailsBoolean; Code: MMResult; begin Code := GetMasterMute(0, MasterMute); if Code = MMSYSERR_NOERROR then begin with Details do begin cbStruct := SizeOf(Details); dwControlID := MasterMute.dwControlID; cChannels := 1; cMultipleItems := 0; cbDetails := SizeOf(BoolDetails); paDetails := @BoolDetails; end; LongBool(BoolDetails.fValue) := Value; Code := mixerSetControlDetails(0, @Details, MIXER_SETCONTROLDETAILSF_VALUE); end; if Code <> MMSYSERR_NOERROR then raise Exception.CreateFmt('SetMasterMuteValue failure, '+ 'multimedia system error #%d',
代码:
);       end;//=========================SetMasterMuteValue(0,true);//静音SetMasterMuteValue(0,False);//还原
 
接受答案了.
 
后退
顶部