用过,可是忘了  :) ,好像有个adjustvolume 还是auxSetVolume的

解决方案 »

  1.   

    试试下面的我也很久没有用过了
    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
      

  2.   

    dwSupport As Long
    End Type
    Private Type VolumeSetting
        LeftVol As Integer
        RightVol As Integer
    End Type
    Private Declare Function auxGetNumDevs Lib "winmm.dll" () As Long
    Private Declare Function auxGetDevCaps Lib "winmm.dll" Alias "auxGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As AUXCAPS, ByVal uSize As Long) As Long
    Private Declare Function auxSetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, ByVal dwVolume As Long) As Long
    Private Declare Function auxGetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, ByRef lpdwVolume As VolumeSetting) As Long
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
    Private Function nSigned(ByVal lUnsignedInt As Long) As Integer
        Dim nReturnVal As Integer                          ' Return value from Function
        If lUnsignedInt > 65535 Or lUnsignedInt < 0 Then
            MsgBox "Error in conversion from Unsigned to nSigned Integer"
            nSignedInt = 0
            Exit Function
        End If
        If lUnsignedInt > 32767 Then
            nReturnVal = lUnsignedInt - 65536
        Else
            nReturnVal = lUnsignedInt
        End If
        nSigned = nReturnVal
    End Function
    Private Function lUnsigned(ByVal nSignedInt As Integer) As Long
        Dim lReturnVal As Long                          ' Return value from Function
        If nSignedInt < 0 Then
            lReturnVal = nSignedInt + 65536
        Else
            lReturnVal = nSignedInt
        End If
        If lReturnVal > 65535 Or lReturnVal < 0 Then
            MsgBox "Error in conversion from nSigned to Unsigned Integer"
            lReturnVal = 0
        End If
        lUnsigned = lReturnVal
    End Function
    Private Function lSetVolume(ByRef lLeftVol As Long, ByRef lRightVol As Long, lDeviceID As Long) As Long
        Dim Volume As VolumeSetting, lBothVolumes As Long
        Volume.LeftVol = nSigned(lLeftVol * 65535 / HIGHEST_VOLUME_SETTING)
        Volume.RightVol = nSigned(lRightVol * 65535 / HIGHEST_VOLUME_SETTING)
        'copy our Volume-variable to a long
        CopyMemory lBothVolumes, Volume.LeftVol, Len(Volume)
        'call the SetVolume-function
        lSetVolume = auxSetVolume(lDeviceID, lBothVolumes)
    End Function
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim Volume As VolumeSetting, Cnt As Long, AC As AUXCAPS
        'set the output to a persistent graphic
        Me.AutoRedraw = True
        'loop through all the devices
        For Cnt = 0 To auxGetNumDevs - 1 'auxGetNumDevs is zero-based
            'get the volume
            auxGetVolume Cnt, Volume
            'get the device capabilities
            auxGetDevCaps Cnt, AC, Len(AC)
            'print the name on the form
            Me.Print "Device #" + Str$(Cnt + 1) + ":  " + Left(AC.szPname, InStr(AC.szPname, vbNullChar) - 1)
            'print the left- and right volume on the form
            Me.Print "Left volume:" + Str$(HIGHEST_VOLUME_SETTING * lUnsigned(Volume.LeftVol) / 65535)
            Me.Print "Right volume:" + Str$(HIGHEST_VOLUME_SETTING * lUnsigned(Volume.RightVol) / 65535)
            'set the left- and right-volume to 50%
            lSetVolume 50, 50, Cnt
            Me.Print "Both volumes now set to 50%"
            'empty line
            Me.Print
        Next
    End Sub
      

  3.   


        我有完整的 API 取得、设置音量的程序,还有取得及设置左右匀衡的功能,还有其它高级功能,我自己写的 。
        
        要的的话 给 200分 ,并留下油箱,我从没食言过!