⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 调用api函数控制系统的音量
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "音量控制"
   ClientHeight    =   2340
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   2340
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command7 
      Caption         =   "恢复原始音量"
      Height          =   495
      Left            =   360
      TabIndex        =   6
      Top             =   1440
      Width           =   3735
   End
   Begin VB.CommandButton Command6 
      Caption         =   "6"
      Height          =   615
      Left            =   3360
      TabIndex        =   5
      Top             =   600
      Width           =   615
   End
   Begin VB.CommandButton Command5 
      Caption         =   "5"
      Height          =   615
      Left            =   2760
      TabIndex        =   4
      Top             =   600
      Width           =   615
   End
   Begin VB.CommandButton Command4 
      Caption         =   "4"
      Height          =   615
      Left            =   2160
      TabIndex        =   3
      Top             =   600
      Width           =   615
   End
   Begin VB.CommandButton Command3 
      Caption         =   "3"
      Height          =   615
      Left            =   1560
      TabIndex        =   2
      Top             =   600
      Width           =   615
   End
   Begin VB.CommandButton Command2 
      Caption         =   "2"
      Height          =   615
      Left            =   960
      TabIndex        =   1
      Top             =   600
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "1"
      Height          =   615
      Left            =   360
      TabIndex        =   0
      Top             =   600
      Width           =   615
   End
   Begin VB.Label Label1 
      Caption         =   "音量控制"
      Height          =   375
      Left            =   360
      TabIndex        =   7
      Top             =   120
      Width           =   2055
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) 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
Dim savvol
Private Sub Command1_Click()
    i = waveOutSetVolume(0, 0)
End Sub

Private Sub Command2_Click()
    i = waveOutSetVolume(0, 600000000)
End Sub

Private Sub Command3_Click()
    i = waveOutSetVolume(0, 1100000000)
End Sub

Private Sub Command4_Click()
    i = waveOutSetVolume(0, -1400000000)
End Sub

Private Sub Command5_Click()
    i = waveOutSetVolume(0, -600000000)
End Sub

Private Sub Command6_Click()
    i = waveOutSetVolume(0, -1)
End Sub

Private Sub Command7_Click()
     '恢复原始音量
    i = waveOutSetVolume(0, savvol)
    End
End Sub

Private Sub Form_Load()
    Me.Show
    '保存当前音量
    i = waveOutGetVolume(0, savvol)
    k = App.Path + "\test.wav"
    l = &H1 Or &H2
    i = sndPlaySound(k, l)
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -