AVI/MPEG Volume must be changed

I need to prorammatically change the PC's volume used to play AVIs and MPEGs. I guess what i really need is a way to change the master system volume from VB.
rblackwellAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

setiawanCommented:
'***************************************************************
'Windows API/Global Declarations for :VolumeGetSet
'***************************************************************
Dim q As String, ahgt, ghtr As String
Dim id As Long, v As Long, i As Long, lVol As lVolType, Vol As VolType, lv As Double, rv As Double


Private Declare Function auxGetVolume Lib "WINMM.DLL" (ByVal uDeviceID As Long, lpdwVolume As Long) As Long


Private Declare Function mciGetDeviceID Lib "WINMM.DLL" Alias "mciGetDeviceIDA" (ByVal lpstrName As String) As Long


Private Declare Function waveOutGetVolume Lib "WINMM.DLL" (ByVal uDeviceID As Long, lpdwVolume As Long) As Long


Private Declare Function waveOutSetVolume Lib "WINMM.DLL" (ByVal uDeviceID As Long, ByVal dwVolume As Long) As Long


Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long


Private Type lVolType
    v As Long
    End Type


Private Type VolType
    lv As Integer
    rv As Integer
    End Type

'***************************************************************
' Name: VolumeGetSet
' Description:Simple function written in VB5 for detecting curren
'     t volume setting, showing
that in a progressbar. Has button Up and Down buttons With hi/low limits that
updates the progressbar.
' By: Dennis James
'
'
' Inputs:None
'
' Returns:Gets and Changes Volume
'
'Assumes:Open New Project, add Progressbar1 and two command butto
'     ns named Command1 and
Command2. Copy Appropriate code to sections. In form load copy "Call Findout"


without the "". Insert Declarations in General Section. Create Sub Findout()
    and copy appropriate code there.
    Set Progressbar from "0 - 10" For min-max. Save and Run.
'
'Side Effects:None
'
'Code provided by Planet Source Code(tm) (http://www.Planet-Sourc
'     e-Code.com) 'as is', without warranties as to performance, fitnes
'     s, merchantability,and any other warranty (whether expressed or i
'     mplied).
'This code is copyrighted by Planet Source Code.
'It may be freely redistributed in a compiled binary executable.
'However, it may not be redistributed in source code form without
'     express written consent from Exhedra Solutions, Inc.
'***************************************************************



Sub Findout()


    id = -0
    i = waveOutGetVolume(id, v)
    lVol.v = v
    LSet Vol = lVol
    lv = Vol.lv: rv = Vol.rv
    lv = lv - &HFFF
    rv = rv - &HFFF
    If lv < -32768 Then lv = 65535 + lv
    If rv < -32768 Then rv = 65535 + rv
    Vol.lv = lv
    Vol.rv = rv
    LSet lVol = Vol
    v = lVol.v
    ghtr = Left(lv, 1)


    If ghtr = "-" Then
        Goto erre
    End If



    If lv < 5000 Then
        q = 1
        Goto sayit
    End If



    If lv < 10000 Then
        q = 2
        Goto sayit
    End If



    If lv < 15000 Then
        q = 3
        Goto sayit
    End If



    If lv < 20000 Then
        q = 4
        Goto sayit
    End If



    If lv < 25000 Then
        q = 5
        Goto sayit
    End If



    If lv < 30000 Then
        q = 6
        Goto sayit
    End If

    erre:


    If lv < (-28000) Then
        q = 7
        Goto sayit
    End If



    If lv < (-22000) Then
        q = 8
        Goto sayit
    End If



    If lv < (-15000) Then
        q = 9
        Goto sayit
    End If



    If lv < (-8000) Then
        q = 10
        Goto sayit
    End If

    sayit:
    ProgressBar1.Value = q
End Sub



Private Sub Command1_Click()



    If q = "1" Then
        Exit Sub
    End If

    id = -0
    i = waveOutGetVolume(id, v)
    lVol.v = v
    LSet Vol = lVol
    lv = Vol.lv: rv = Vol.rv
    lv = lv - &HFFF
    rv = rv - &HFFF
    If lv < -32768 Then lv = 65535 + lv
    If rv < -32768 Then rv = 65535 + rv
    Vol.lv = lv
    Vol.rv = rv
    LSet lVol = Vol
    v = lVol.v
    i = waveOutSetVolume(id, v)
    Call Findout
End Sub



Private Sub Command2_Click()



    If q = "10" Then
        Exit Sub
    End If

    Dim dfre
    j = 1
    id = -0
    i = waveOutGetVolume(id, v)
    lVol.v = v
    LSet Vol = lVol
    lv = Vol.lv: rv = Vol.rv
    lv = lv + &HFFF
    rv = rv + &HFFF
    'If lv <= -30000 Then Exit Sub
    If lv > 32767 Then lv = lv - 65536
    If rv > 32767 Then rv = rv - 65536
    Vol.lv = lv
    Vol.rv = rv
    LSet lVol = Vol
    v = lVol.v
    i = waveOutSetVolume(id, v)
    Call Findout
End Sub



Private Sub Form_Load()

    Call Findout
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.