用户名: 密   码:
   飞诺网 加入收藏
飞诺网 网站开发 VBScript ASP Asp.net Jsp php XML CGI-Perl 搜索引擎 ajax web技术
.net系列教程 .net实例 .Net技术文档

您当前的位置:飞诺网 >> .net >> .net系列教程

VB.net里面控制系统音量

www.diybl.com    时间 : 2011-08-03  作者:网络   编辑:hawk 点击:   [ 评论 ]

  

Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class Form1
Inherits System.Windows.Forms.Form

Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Integer
  
Private Declare Function waveOutSetVolume Lib "winmm.dll" (ByVal uDeviceID As Integer, ByVal dwVolume As Integer) As Integer
Private Declare Function waveOutGetVolume Lib "winmm.dll" (ByVal uDeviceID As Integer, ByRef lpdwVolume As Integer) As Integer

    Const Wave_mapper As Short = -1

    Public Function Setlr(ByVal Lvolume As Integer, ByVal Rvolume As Integer) As Integer
        Dim mlr As String
        mlr = "&h" & VB.Right("0000" & Hex(Lvolume), 4) & VB.Right("0000" & Hex(Rvolume), 4)
        waveOutSetVolume(Wave_mapper, CInt(mlr))
    End Function

    Public Function Getlr(ByRef l As Integer, ByRef r As Integer) As Integer
        Dim lr As Integer
        waveOutGetVolume(Wave_mapper, lr)
        l = CInt("&h" & VB.Left(Hex(lr), 4))
        r = CInt("&h" & VB.Right(Hex(lr), 4))
    End Function
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Dim ml, mr As Integer
        Getlr(ml, mr)
        MsgBox("左声道" & ml & "--右声道" & mr)
End Sub

Private Sub command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles command1.Click
Setlr(CInt(Text1.Text), CInt(Text2.Text))
End Sub
End Class
如果图片或页面不能正常显示请点击这里
.net系列教程推荐文章

文章评论