Home > Back-end >  Add 60 points, find the master code, but not to use, everybody to give directions
Add 60 points, find the master code, but not to use, everybody to give directions

Time:10-21

Volume control and mute "in the" Delphi is a veteran house blog. His code not wrong, but since there is no form, never make, don't know how to get, who can change it to have a form's code, two knot put together! Thank you

The unit UMute;
Interface
USES MMSystem, Dialogs.
Type
TDeviceName=(Master, Microphone, WaveOut, Synth);
The function GetVolume (DN: TDeviceName) : Word;
Procedure SetVolume (DN: TDeviceName; Value: the Word);
The function GetVolumeMute (DN: TDeviceName) : Boolean;
Procedure SetVolumeMute (DN: TDeviceName; Value: Boolean);
Implementation
//get the volume
The function GetVolume (DN: TDeviceName) : Word;
Var
HMix: HMIXER;
MXLC: MIXERLINECONTROLS;
MXCD: TMIXERCONTROLDETAILS;
Vol: TMIXERCONTROLDETAILS_UNSIGNED;
MXC: MIXERCONTROL;
MXL: TMixerLine;
IntRet: Integer;
NMixerDevs: Integer;
The begin
Result:=0;
//Check if Mixer is
NMixerDevs: mixerGetNumDevs=();
If (nMixerDevs & lt; 1) then the Exit;
//open the mixer
IntRet:=mixerOpen (@ hMix, 0, 0, 0, 0).
If intRet=MMSYSERR_NOERROR then begin
In case of a DN
Master: MXL. DwComponentType:=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
Microphone: MXL. DwComponentType:=MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE;
WaveOut: MXL. DwComponentType:=MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
Synth: MXL. DwComponentType:=MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER;
end;
MXL. CbStruct:=SizeOf (MXL);
//get the line 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_VOLUME;
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. DwControlID:=MXC. DwControlID;
MXCD. CbStruct:=SizeOf (MXCD);
MXCD. CMultipleItems:=0;
MXCD. CbDetails:=SizeOf (Vol);
MXCD. PaDetails:=@ vol.
MXCD. CChannels:=1;
IntRet:=mixerGetControlDetails (hMix, @ MXCD MIXER_SETCONTROLDETAILSF_VALUE);
Result:=vol. The dwValue;
If intRet & lt;> MMSYSERR_NOERROR then
ShowMessage (' GetControlDetails Error ");
End the else
ShowMessage (' GetLineInfo Error ");
end;
MixerClose (hMix);
end;
end;
//set the volume
Procedure setVolume (DN: TDeviceName; Value: the Word);
Var
HMix: HMIXER;
MXLC: MIXERLINECONTROLS;
MXCD: TMIXERCONTROLDETAILS;
Vol: TMIXERCONTROLDETAILS_UNSIGNED;
MXC: MIXERCONTROL;
MXL: TMixerLine;
IntRet: Integer;
NMixerDevs: Integer;
The begin
//Check if Mixer is
NMixerDevs: mixerGetNumDevs=();
If (nMixerDevs & lt; 1) then the Exit;
//open the mixer
IntRet:=mixerOpen (@ hMix, 0, 0, 0, 0).
If intRet=MMSYSERR_NOERROR then begin
In case of a DN
Master: MXL. DwComponentType:=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
Microphone: MXL. DwComponentType:=MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE;
WaveOut: MXL. DwComponentType:=MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
Synth: MXL. DwComponentType:=MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER;
end;
MXL. CbStruct:=SizeOf (MXL);
//get the line 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_VOLUME;
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. DwControlID:=MXC. DwControlID;
MXCD. CbStruct:=SizeOf (MXCD);
MXCD. CMultipleItems:=0;
MXCD. CbDetails:=SizeOf (Vol);
MXCD. PaDetails:=@ vol.
MXCD. CChannels:=1;
Vol. The dwValue:=Value;
IntRet:=mixerSetControlDetails (hMix, @ MXCD MIXER_SETCONTROLDETAILSF_VALUE);
If intRet & lt;> MMSYSERR_NOERROR then
ShowMessage (' SetControlDetails Error ");
End the else
ShowMessage (' GetLineInfo Error ");
end;
MixerClose (hMix);
end;
end;
//get mute
The function GetVolumeMute (DN: TDeviceName) : Boolean;
Var
HMix: HMIXER;
MXLC: MIXERLINECONTROLS;
MXCD: TMIXERCONTROLDETAILS;
MXC: MIXERCONTROL;
MXL: TMixerLine;
IntRet: Integer;
NMixerDevs: Integer;
McDMute: MIXERCONTROLDETAILS_BOOLEAN;
The begin
//Check if Mixer is
NMixerDevs: mixerGetNumDevs=();
Result:=False;
If (nMixerDevs & lt; 1) then the Exit;
//open the mixer
IntRet:=mixerOpen (@ hMix, 0, 0, 0, 0).
If intRet=MMSYSERR_NOERROR then begin
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related