unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, MPlayer, StdCtrls, CheckLst, ExtCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Play: TButton;<br> MediaPlayer1: TMediaPlayer;<br> CheckListBox1: TCheckListBox;<br> Next: TButton;<br> Timer1: TTimer;<br> procedure Resource;<br> procedure PlayClick(Sender: TObject);<br> procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br> procedure FormCreate(Sender: TObject);<br> procedure NextClick(Sender: TObject);<br> procedure Timer1Timer(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br>{$R lsf.res}<br><br>procedure TForm1.PlayClick(Sender: TObject);<br>begin<br> MediaPlayer1.Close;<br> DeleteFile('c:/temp.mp3');<br> Resource;<br> MediaPlayer1.FileName:='c:/temp.mp3';<br> MediaPlayer1.open;<br> MediaPlayer1.Play;<br> Timer1.Enabled :=true;<br>end;<br><br>procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br>begin<br> MediaPlayer1.Close;<br> DeleteFile('c:/temp.mp3');<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> Checklistbox1.ItemIndex := 0;<br>end;<br><br>procedure TForm1.NextClick(Sender: TObject); //下一首<br>begin<br> if Checklistbox1.ItemIndex =Checklistbox1.Count-1 then<br> Checklistbox1.ItemIndex :=0<br> else<br> Checklistbox1.ItemIndex :=Checklistbox1.ItemIndex+1;<br> Form1.PlayClick(sender);<br>end;<br><br>//主要在下面这段 如:当前Checklistbox1.Items.Strings[Checklistbox1.ItemIndex]:=music01<br>现在 Checklistbox1.ItemIndex:=Checklistbox1.ItemIndex+1 ---->music02<br>要删除内存中music01所占的内存资源,该如何?<br><br>procedure TForm1.Resource; //读取资源、释放已经没用的资源(未实现)<br>var<br> R: TResourceStream;<br>begin<br> r:=TResourceStream.Create(HInstance, Checklistbox1.Items.Strings[Checklistbox1.ItemIndex] , 'mp3');<br> r.SaveToFile('c:/temp.mp3');<br> r.Free;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br> if MediaPlayer1.Position >=MediaPlayer1.Length then<br> begin<br> if Checklistbox1.ItemIndex =Checklistbox1.Count-1 then<br> Checklistbox1.ItemIndex :=0<br> else<br> Checklistbox1.ItemIndex :=Checklistbox1.ItemIndex+1;<br> Form1.PlayClick(sender);<br> end;<br>end;<br><br>end.