# OK了

Posted by Honey on December 08, 1998 at 23:46:26:

In Reply to: 到MSDN上找VB的Knowledge Base posted by 帅帅阿柳 on December 08, 1998 at 17:39:37:

也许你想不到吧
这个API我花了近六小时
才找出6553700这数
挺复杂的 因为间距不对
会调到左右声道 而不是声音大小
这数字我也好不容易才凑到
不过 心理真的好高兴

做法是在Form上放一个 Hscroll1
然后贴上以下程式

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
Const WAVE_MAPPER = -1&
Dim h As Long, j As Integer
Dim k As Long, l As Integer
Option Explicit

Private Sub Form_Load()
HScroll1.Max = 652
HScroll1.Min = 0
HScroll1.LargeChange = 100
HScroll1.SmallChange = 10
Call waveOutGetVolume(WAVE_MAPPER, k)
h = k \ 6553700
If h <= 0 Then
HScroll1.Value = HScroll1.Max + h
Else
HScroll1.Value = h
End If
End Sub

Private Sub HScroll1_Change()
h = HScroll1.Value
If h <= 326 Then
k = 6553700 * h
Else
k = (h - 652) * 6553700 - 1
End If
Call waveOutSetVolume(WAVE_MAPPER, k)
End Sub

Follow Ups:

- Re: 谢谢你! 另外如何才能控制到(主控音量)呢? Headache Man 23:41:01 12/09/98 (0)