Is there an API to GET the current speaker volume setting?
WinMM. I take this code from MASM example.
;Code by Wiliam F.
GetMasterVolume proc
invoke mixerOpen,ADDR MixerHandle,0,0,0,0
.if eax == MMSYSERR_NOERROR
mov mxlc.cbStruct,SIZEOF mxlc
mov mxlc.dwLineID,SPEAKEROUTLINEID
mov mxlc.dwControlType,MIXERCONTROL_CONTROLTYPE_VOLUME
mov mxlc.cControls,1
mov mxlc.cbmxctrl,SIZEOF mxc
mov mxlc.pamxctrl,OFFSET mxc
invoke mixerGetLineControls,MixerHandle,ADDR mxlc,MIXER_GETLINECONTROLSF_ONEBYTYPE
mov eax,mxc.dwControlID
mov VolCtlIDMtr,eax
mov mxcdVol.dwValue,1
mov mxcd.cbStruct,SIZEOF mxcd
mov eax,VolCtlIDMtr
mov mxcd.dwControlID,eax
mov mxcd.cChannels,1
mov mxcd.cMultipleItems,0
mov mxcd.cbDetails,SIZEOF mxcdVol
mov mxcd.paDetails,OFFSET mxcdVol
invoke mixerGetControlDetails,MixerHandle,ADDR mxcd,MIXER_GETCONTROLDETAILSF_VALUE
mov eax,mxcdVol[0].dwValue
.else
mov eax,MIXER_ERROR
.endif
ret
GetMasterVolume endp
; ###############################################################
SetMasterVolume proc VolValue:DWORD
mov eax,VolValue
mov mxcdVol[0].dwValue,eax
mov mxcd.cbStruct,SIZEOF mxcd
mov eax,VolCtlIDMtr
mov mxcd.dwControlID,eax
mov mxcd.cChannels,1
mov mxcd.cMultipleItems,0
mov mxcd.cbDetails,SIZEOF mxcdVol
mov mxcd.paDetails,OFFSET mxcdVol
invoke mixerSetControlDetails,MixerHandle,ADDR mxcd,MIXER_GETCONTROLDETAILSF_VALUE
.if eax == MMSYSERR_NOERROR
mov eax,0
.else
mov eax,MIXER_ERROR
.endif
ret
SetMasterVolume endp
; ###############################################################
CloseMasterVolume proc
invoke mixerClose,ADDR MixerHandle
ret
CloseMasterVolume endp
But I cannot get this code to work.
Thanks Farabi, it gives me a start .
This is a modified version of the 'VolCtrl' in the Masm examples. You now can specify which control of the mixer you want to adjust.
I hope this is of some use.
dougiem.
[attachment deleted by admin]
Thanks dougiem. EXACTLY what I needed. Works great.