我建议你调用windows的那个程序。
就是音量调节的。
比较全一些。

解决方案 »

  1.   

    调用setwaveoutvolume
    setmidioutvolume
      

  2.   

    这个问题也困扰了我很久,我可以在程序中分别控制wav、mid、cd的音量,却无法控制系统的总音量。帮你UP!
      

  3.   

    给你一段程序,试一试对不对  :)unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      Mmsystem, ComCtrls, StdCtrls;type
      TForm1 = class(TForm)
        TrackBar1: TTrackBar;
        TrackBar2: TTrackBar;
        TrackBar3: TTrackBar;
        Label1: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        procedure TrackBar1Change(Sender: TObject);
        procedure TrackBar2Change(Sender: TObject);
        procedure TrackBar3Change(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.TrackBar1Change(Sender: TObject);
    var
      t, v: longint;
      //t的最大值为8位的二进制:11111111;
      //用v来表示音量的大小,这是个32为的整数
      //,高16位表示右声道的音量,低16为表示
      //左声道的音量
    begin
      t := Trackbar1.Position;//得到Trackbar的位置,
      //可用这个值来表示音量的大小
      v := (t shl 8) or (t shl 24);//将t作移8位、24位
      waveoutsetvolume(0,v);//设置音量
      Label4.Caption := IntToStr(Trackbar1.Position);
    end;procedure TForm1.TrackBar2Change(Sender: TObject);
    var
      t, v: longint;
    begin
      t := Trackbar2.Position;
      waveoutgetvolume(0, @v);//@表示指向变量v的指针(32位)
      //调用此函数的用意是得到右声道的值,做到在调节左声道的
      //时候,不改变右声道
      v := v and $ffff0000 or (t shl 8);//数字前加$表示式十六进制的数字
      waveoutsetvolume(0,v);
      Label5.Caption := IntToStr(Trackbar2.Position);
    end;procedure TForm1.TrackBar3Change(Sender: TObject);
    var
      t, v: longint;
    begin
      t := Trackbar3.Position;
      waveoutgetvolume(0, @v);
      v := v and $0000ffff or (t shl 24);
      waveoutsetvolume(0,v);
      Label6.Caption := IntToStr(Trackbar3.Position);
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
      v: longint;
    begin
      waveoutgetvolume(0, @v);//得到现在的音量
      trackbar2.Position := hi(v);//设置左声道滑块的正确位置
      trackbar3.Position := hi(v shr 16);//设置右声道滑块的正确位置
    //注:函数hi(v)的作用为:返回一个16位无符号整数的高8位
    //如果v为32位,则高16位自动被自动忽略了。
    //只用高8位时可是调节更明显。
    //对波形文件可以用wavoutgetvolume函数, 对于cd文件可以用
    //auxgetvolume函数end;end.
      

  4.   

    //音量调节没有这么复杂,看我的
    //下面是个单元,包含到工程中就可以用了!!!!
    unit SetVolumeUnit;
    interface
    uses
      Windows,mmSystem;
    Var
      LeftVolume,RightVolume : WORD;
      Volume : DWORD;
    procedure InitVolume;
    procedure SetLeftVolume(Value : WORD);
    procedure SetRightVolume(Value: WORD);
    procedure SetVolume(Value : DWORD);
    function  GetLeftVolume : WORD;
    function  GetRightVolume: WORD;
    function  GetVolume: DWORD;
    implementation
    procedure InitVolume;
    var
     InitVolume1 : DWORD;
    begin
      WaveOutGetVolume(0,@InitVolume1);
      LeftVolume:=LOWORD(InitVolume1);
      RightVolume:=HIWORD(InitVolume1);
      Volume:=InitVolume1;
    end;
    procedure SetLeftVolume(Value : WORD);//设置左声道
    begin
       LeftVolume:=Value;
       Volume:=MAKELONG(RightVolume,LeftVolume);
       WaveOutSetVolume(0,Volume);
    end;
    procedure SetRightVolume(Value : WORD);//设置右声道
    begin
       RightVolume:=Value;
       Volume:=MAKELONG(RightVolume,LeftVolume);
       WaveOutSetVolume(0,Volume);
    end;
    procedure SetVolume(Value : DWORD);
    begin
       Volume:=Value;
       WaveOutSetVolume(0,Volume);
    end;
    Function GetLeftVolume : WORD;
    begin
      Result:=LeftVolume;
    end;
    Function GetRightVolume: WORD;
    begin
      Result:=RightVolume;
    end;
    Function GetVolume : DWORD;
    begin
      Result:=Volume;
    end;
    initialization
     InitVolume;
    end.
      

  5.   

    各位大哥:首先感谢大家对我的帮助,不过你们的介绍只是控制WAVE的音量,而不是总的音量。我想求助控制总音量的函数。
      

  6.   

    上面的给我一份吧:[email protected]
      

  7.   

    http://www.codeproject.com/audio/volctrl.asp不过是C++的。 可以参考参考。