J
jimowutong
Unregistered / Unconfirmed
GUEST, unregistred user!
请注意,下面这种在2k或XP下可用但对Vista无效:
procedure SetVolumeMute(Value: Boolean);
var
hMix: HMIXER;
mxlc: MIXERLINECONTROLS;
mxcd: TMIXERCONTROLDETAILS;
mxc: MIXERCONTROL;
mxl: TMixerLine;
intRet: Integer;
nMixerDevs: Integer;
mcdMute: MIXERCONTROLDETAILS_BOOLEAN;
begin
try
// Check if Mixer is available
nMixerDevs := mixerGetNumDevs();
if (nMixerDevs < 1) then
begin
Exit;
end;
// open the mixer
intRet := mixerOpen(@hMix, 0, 0, 0, 0);
if intRet = MMSYSERR_NOERROR then
begin
mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
mxl.cbStruct := SizeOf(mxl);
// mixerline info
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;
// Get the mute control
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 := @mcdMute;
// Set and UnSet mute
mcdMute.fValue := Ord(Value);
intRet := mixerSetControlDetails(hMix, @mxcd,
MIXER_SETCONTROLDETAILSF_VALUE);
{if intRet <> MMSYSERR_NOERROR then
ShowMessage('SetControlDetails Error');}
end
else
{ShowMessage('GetLineInfo Error'); }
end;
mixerClose(hMix);
end;
except
on Exception do ;
end;
end;
===========================================================================
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1631182&SiteID=1
上面网址有相关探讨,可惜我不会用
谁能搞定的话我的QQ: 44401015
非常感谢。
procedure SetVolumeMute(Value: Boolean);
var
hMix: HMIXER;
mxlc: MIXERLINECONTROLS;
mxcd: TMIXERCONTROLDETAILS;
mxc: MIXERCONTROL;
mxl: TMixerLine;
intRet: Integer;
nMixerDevs: Integer;
mcdMute: MIXERCONTROLDETAILS_BOOLEAN;
begin
try
// Check if Mixer is available
nMixerDevs := mixerGetNumDevs();
if (nMixerDevs < 1) then
begin
Exit;
end;
// open the mixer
intRet := mixerOpen(@hMix, 0, 0, 0, 0);
if intRet = MMSYSERR_NOERROR then
begin
mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
mxl.cbStruct := SizeOf(mxl);
// mixerline info
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;
// Get the mute control
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 := @mcdMute;
// Set and UnSet mute
mcdMute.fValue := Ord(Value);
intRet := mixerSetControlDetails(hMix, @mxcd,
MIXER_SETCONTROLDETAILSF_VALUE);
{if intRet <> MMSYSERR_NOERROR then
ShowMessage('SetControlDetails Error');}
end
else
{ShowMessage('GetLineInfo Error'); }
end;
mixerClose(hMix);
end;
except
on Exception do ;
end;
end;
===========================================================================
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1631182&SiteID=1
上面网址有相关探讨,可惜我不会用
谁能搞定的话我的QQ: 44401015
非常感谢。