怎样用VB控制系统音量的大小,要求不能使用第三方控件。谢谢

解决方案 »

  1.   

    http://www.sijiqing.com/vbgood/experience/index.asp?action=read&id=3164
      

  2.   

    'Example submitted by Danjel Nyberg
    'It needs a textbox (Text1) and two command buttons (Command1, Command2)
    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
    Private Sub Command1_Click()
        Dim a, i As Long
        Dim tmp As String
        a = waveOutGetVolume(0, i)
        tmp = "&h" & Right(Hex$(i), 4)
        Text1 = CLng(tmp)
    End Sub
    Private Sub Command2_Click()
        Dim a, i As Long
        Dim tmp, vol As String
        vol = Text1
        tmp = Right((Hex$(vol + 65536)), 4)
        vol = CLng("&H" & tmp & tmp)
        a = waveOutSetVolume(0, vol)
    End Sub
    ==============================
    上面的例子是控制音量中的 WAVE ,同样可以调节大小这里还有例子:
    http://expert.csdn.net/Expert/topic/1543/1543099.xml?temp=.8272211
    http://expert.csdn.net/Expert/topic/1433/1433239.xml?temp=.6692469你怎么还不会自己去搜索以前的帖子? 就搜"音量",帖子大把!