你试试下面的程序,这是很早以前写的,应可以满足你的要求
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, mmsystem, StdCtrls, MPlayer;
type
TForm1 = class(TForm)
TrackBar1: TTrackBar;
TrackBar2: TTrackBar;
TrackBar3: TTrackBar;
TrackBar4: TTrackBar;
Button: TButton;
MediaPlayer: TMediaPlayer;
OpenDialog: TOpenDialog;
procedure TrackBar1Change(Sender: TObject);
procedure TrackBar2Change(Sender: TObject);
procedure TrackBar3Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TrackBar4Change(Sender: TObject);
procedure ButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ID:word;
implementation
{$R *.DFM}
procedure TForm1.TrackBar1Change(Sender: TObject);
var
t,v:Longint;
begin
// if a=0 then
Exit;
t:=TrackBar1.Position;
v:=(t shl 8)or(t shl 24);
waveOutSetVolume(ID,v);
end;
procedure TForm1.TrackBar2Change(Sender: TObject);
var
t,v:Longint;
begin
t:=TrackBar2.Position;
waveOutGetVolume(ID,@v);
v:=v and $ffff0000 or (t shl 8);
waveOutSetVolume(ID,v);
end;
procedure TForm1.TrackBar3Change(Sender: TObject);
var
t,v:Longint;
begin
t:=TrackBar3.Position;
waveOutGetVolume(ID,@v);
v:=v and $0000ffff or (t shl 24);
waveOutSetVolume(ID,v);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
v:longint;
begin
waveOutGetVolume(ID,@v);
TrackBar2.Position:=hi(v);
TrackBar3.Position:=hi(v shr 16);
if hi(v)>hi(v shr 16) then
TrackBar1.Position:=hi(v)
else
TrackBar1.Position:=hi(v shr 16);
auxGetVolume(ID,@v);
if hi(v)>hi(v shr 16) then
TrackBar4.Position:=hi(v)
else
TrackBar4.Position:=hi(v shr 16);
end;
procedure TForm1.TrackBar4Change(Sender: TObject);
var
t,v:Longint;
begin
// if a=0 then
Exit;
t:=TrackBar1.Position;
v:=(t shl 8)or(t shl 24);
auxSetVolume(0,v);
//auxSetVolume
end;
procedure TForm1.ButtonClick(Sender: TObject);
begin
if OpenDialog.Execute then
begin
MediaPlayer.FileName:=OpenDialog.FileName;
MediaPlayer.Open;
ID:=MediaPlayer.DeviceID;
end;
end;
end.