5,388
社区成员
发帖
与我相关
我的任务
分享
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons,shellapi;
type
TForm1 = class(TForm)
zj: TComboBox;
gq: TComboBox;
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure zjChange(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
function executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle;
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
filename,path:string;
implementation
{$R *.dfm}
procedure TForm1.zjChange(Sender: TObject);
begin
case zj.ItemIndex of
0,1,2:path:='h:\a'+inttostr(zj.ItemIndex +1);
3,4,5:path:='h:\b'+inttostr(zj.ItemIndex +1);
end;
filename:=inttostr(zj.itemindex+1)+'.txt';
gq.Items.LoadFromFile (filename);
gq.Text:=gq.Items.Strings [0];
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
case gq.ItemIndex of
0,1,2:filename:=path+'\'+'0'+inttostr(gq.ItemIndex +1)+'.mp3';
3,4,5:filename:=path+'\'+'mp3';
else
filename:=path+'\a.mp3';
end;
executefile('wmplayer.exe','','C:\Program Files\Windows Media Player ',sw_hide);
end;
function executefile(const filename,params,defaultdir:string;showcmd:integer):Thandle;
var
zfilename,zparams,zdir:array[0..5] of char;
begin
result:=shellexecute(application.MainForm .handle,nil,
strpcopy(zfilename,filename),strpcopy(zparams,params),
strpcopy(zdir,defaultdir),showcmd);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
close;
end;
end.