C# 调用winmm来设置音量

C# 调用winmm来设置音量

using System;
 
using System.Runtime.InteropServices;
 
 
 
namespace Microsoft
 
{
 
 
 
     public class AudioMixerHelper
 
     {
 
         public const int MMSYSERR_NOERROR = 0;
 
         public const int MAXPNAMELEN = 32;
 
         public const int MIXER_LONG_NAME_CHARS = 64;
 
         public const int MIXER_SHORT_NAME_CHARS = 16;
 
         public const int MIXER_GETLINEINFOF_COMPONENTTYPE  = 0x3;
 
         public const int MIXER_GETCONTROLDETAILSF_VALUE = 0x0;
 
         public const int MIXER_GETLINECONTROLSF_ONEBYTYPE  = 0x2;
 
         public const int MIXER_SETCONTROLDETAILSF_VALUE = 0x0;
 
         public const int MIXERLINE_COMPONENTTYPE_DST_FIRST = 0x0;
 
         public const int MIXERLINE_COMPONENTTYPE_SRC_FIRST = 0x1000;
 
         public const int MIXERLINE_COMPONENTTYPE_DST_SPEAKERS =
 
              (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4);
 
         public const int MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE =
 
              (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3);
 
         public const int MIXERLINE_COMPONENTTYPE_SRC_LINE =
 
              (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2);
 
         public const int MIXERCONTROL_CT_CLASS_FADER = 0x50000000;
 
         public const int MIXERCONTROL_CT_UNITS_UNSIGNED = 0x30000;
 
         public const int MIXERCONTROL_CONTROLTYPE_FADER =
 
              (MIXERCONTROL_CT_CLASS_FADER | MIXERCONTROL_CT_UNITS_UNSIGNED);
 
         public const int MIXERCONTROL_CONTROLTYPE_VOLUME =
 
              (MIXERCONTROL_CONTROLTYPE_FADER + 1);
 
 
 
         [DllImport("winmm.dll", CharSet=CharSet.Ansi)]
 
         private static extern int mixerClose (int hmx);
 
         [DllImport("winmm.dll", CharSet=CharSet.Ansi)]
 
         private static extern int mixerGetControlDetailsA (int hmxobj,ref
 
              MIXERCONTROLDETAILS pmxcd , int fdwDetails);
 
         [DllImport("winmm.dll", CharSet=CharSet.Ansi)]
 
         private static extern int mixerGetDevCapsA(int uMxId, MIXERCAPS
 
              pmxcaps, int cbmxcaps);
 
         [DllImport("winmm.dll", CharSet=CharSet.Ansi)]
 
         private static extern int mixerGetID (int hmxobj, int pumxID, int
 
              fdwId);
 
         [DllImport("winmm.dll", CharSet=CharSet.Ansi)]
 
         private static extern int  mixerGetLineControlsA (int hmxobj,ref
 
              MIXERLINECONTROLS pmxlc, int fdwControls);
 
         [DllImport("winmm.dll", CharSet=CharSet.Ansi)]
 
         private static extern int  mixerGetLineInfoA (int hmxobj,ref
 
              MIXERLINE pmxl , int fdwInfo);
 
         [DllImport("winmm.dll", CharSet=C
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值