Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System Volume 1

Status
Not open for further replies.

Interloper

Programmer
Apr 23, 2002
6
US
How would I make an ActiveX control that would turn the system volume up to full?
 
Interloper,

Use a Call to the API Function:- waveOutSetVolume, waveOutGetVolume

Private Declare Function waveOutSetVolume Lib "Winmm" (ByVal wDeviceID As Integer, ByVal dwVolume As Long) As Integer

Private Declare Function waveOutGetVolume Lib "Winmm" (ByVal wDeviceID As Integer, dwVolume As Long) As Integer

New volume setting. The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and the high-order word is ignored.

Private Sub Command1_Click()

SetSystemVolume 10000

MsgBox GetSystemVolume
End Sub

Function GetSystemVolume() As Long

On Error GoTo errhandler

'Local Variables
Dim i As Integer
Dim sHex As String
Dim lVolume As Long

'Get System Volume
i = waveOutGetVolume(0, lVolume)

'Get Hex of Volume
sHex = "&h" & Right(Hex$(lVolume), 4)

'Return System Volume
GetSystemVolume = CLng(sHex)

Exit Function

errhandler:
'Error

End Function

Function SetSystemVolume(lVolume As Long) As Boolean

On Error GoTo errhandler

Dim i As Integer
Dim sHex As String

'Get Hex of Volume
sHex = Right((Hex$(lVolume + 65536)), 4)

'Get Long Value Left and Right Channel Settings
lVolume = CLng("&H" & sHex & sHex)

'Set System Volume
i = waveOutSetVolume(0, lVolume)

'Return Success
SetSystemVolume = True

Exit Function

errhandler:
'Error
SetSystemVolume = False

End Function


Regards,

Codefish
 
I remember a small program that went around in email. It would turn your volume up to full, and then play a WAV, that said. "HEY EVERYBODY I'M WATCHING 'CARTOONS' OVER HERE"...

Craig, mailto:sander@cogeco.ca

Remember not to name the Lambs...
It only makes the chops harder to swallow
 
Well... that's not exactly the use that I had in mind.
 
Codefish,

What is the API Function to set the system volume? I tried to view the winmm library, but it appeared as mostly gibberish.

Thanks.
 
Interloper,

I don't understand your question, The API Function is called waveOutSetVolume like stated above. winmm.dll is the C dll where waveOutSetVolume is located.

Codefish
 
Under volume control, you see Volume Control, Line in, Microphone, Wave Output, FM Synth, CD Audio, and Four Speaker. That function adjusts only the wave output; I want to know the function that adjust the system volume or Volume Control as it is labeled under volume control. Sorry I was too vague on that. Can I open that dll file with anything to find out what other API Functions it has?
 
Hi Interloper,

I see what you mean now.

This 'volume control' (found in Control Panel), along with the other properties like microphone, CD audio etc. , make up the Mixer Contol and are controlled by a set of API calls below:-


Private Declare Function mixerGetNumDevs Lib "winmm.dll" () As Long

Private Declare Function mixerOpen Lib "winmm.dll" (phmx As Long, ByVal uMxId As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal fdwOpen As Long) As Long

Private Declare Function mixerClose Lib "winmm.dll" (ByVal hmx As Long) As Long

Private Declare Function mixerGetLineInfo Lib "winmm.dll" Alias "mixerGetLineInfoA" (ByVal hmxobj As Long, pmxl As MIXERLINE, ByVal fdwInfo As Long) As Long

Private Declare Function mixerGetLineControls Lib "winmm.dll" Alias "mixerGetLineControlsA" (ByVal hmxobj As Long, pmxlc As MIXERLINECONTROLS, ByVal fdwControls As Long) As Long

Private Declare Function mixerGetControlDetails Lib "winmm.dll" Alias "mixerGetControlDetailsA" (ByVal hmxobj As Long, pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Long) As Long

Private Declare Function mixerSetControlDetails Lib "winmm.dll" (ByVal hmxobj As Long, pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Long) As Long


I have Code to do this - I'll dig it out and submit it.

Regards,

Codefish

 
HI codefish

I used the routines above after looking in a file called VOLUM.EXE on the MS support site but I have yet to find anything or anyone that can tell me where/how to select the record input and it's volume not the Aux Volume (out or record). Any ideas ???

I set volume easily on all normal out sliders except Aux but got only the combined of the outs in the record section.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top