本人做的歌曲文件格式自动恢复代码,完整源代码可跟我联系 UC:65510499
procedure TForm1.Button3Click(Sender: TObject);
var
a:integer;
i:integer;
buff1:array [0..3] of byte;
changDAT,changVOB:boolean;
newfilename:string;
begin
if listbox1.Count=0 then
exit;
ProgressBar1.Min:=0;
ProgressBar1.Max:=listbox1.Count-1;
ProgressBar1.Position:=0;
for i:=0 to listbox1.Count-1do
begin
if checkbox1.Checked then
//批量改名
begin
newfilename:=copy(listbox1.Items.Strings,0,pos('.',listbox1.Items.Strings))
+ edit3.Text;
RenameFile(listbox1.Items.Strings,newfilename);
listbox1.Items.Strings:=newfilename;
end;
if CheckBox2.Checked then
//自动识别DAT/Vob文件
begin
a:=FileOpen(listbox1.Items.Strings,fmOpenRead);
if a>0 then
begin
changDAT:=false;
changVOB:=false;
FileRead(a,buff1,sizeof(buff1));
if (buff1[0]=$52) and (buff1[1]=$49) and (buff1[2]=$46) and (buff1[3]=$46) then
changDAT:=True;
if (buff1[0]=$00) and (buff1[1]=$00) and (buff1[2]=$01) and (buff1[3]=$BA) then
changVOB:=True;
fileclose(a);
if changDAT then
begin
newfilename:=copy(listbox1.Items.Strings,0,pos('.',listbox1.Items.Strings))
+ 'DAT';
RenameFile(listbox1.Items.Strings,newfilename);
listbox1.Items.Strings:=newfilename;
end;
if changVOB then
begin
newfilename:=copy(listbox1.Items.Strings,0,pos('.',listbox1.Items.Strings))
+ 'VOB';
RenameFile(listbox1.Items.Strings,newfilename);
listbox1.Items.Strings:=newfilename;
end;
end
end;
//自动识别完成
ProgressBar1.Position:=i;
end;
end;