我不想用控件,有什么办法嘛?我用
file_name:='d:\htys\tmp_data.rar';
dbpath := 'd:\tmp';
aa:='winrar e -o+ '+file_name+' '+dbpath;
if not fileexists(file_name) then
begin
messagebox(handle,pchar(file_name+'文件不存在,无法进行解压缩操作!'),'提示信息',0);
exit;
end; if winexec(pchar(aa),sw_hide)<=31 then
begin
messagebox(handle,'解压缩操作失败!','提示信息',0);
exit;
end;
这个他提示解压失败呢,
file_name:='d:\htys\tmp_data.rar';
dbpath := 'd:\tmp';
aa:='winrar e -o+ '+file_name+' '+dbpath;
if not fileexists(file_name) then
begin
messagebox(handle,pchar(file_name+'文件不存在,无法进行解压缩操作!'),'提示信息',0);
exit;
end; if winexec(pchar(aa),sw_hide)<=31 then
begin
messagebox(handle,'解压缩操作失败!','提示信息',0);
exit;
end;
这个他提示解压失败呢,
begin
ZipName:=dstFile;
RecreateDirs:=true; //注意这里
StorePaths:=False;
FilesList.Add(srcFile);
Recurse := True;
try
Zip;
except
Application.MessageBox('压缩文件失败','错误',MB_OK+MB_ICONINFORMATION);
exit;
end;
end;解压缩:vcluzip:=TVCLUnZip.Create(nil);
with vcluzip do
begin
ZipName:=sFile;
ReadZip;
FilesList.Add('*.*');
DoAll := False;
DestDir := ExtractFilePath(sFile);
RecreateDirs := False;
RetainAttributes := True;
Unzip;
end;
vcluzip.Free;
file_name:='d:\pp.rar'; //解压的文件
dbpath := '*.bak'; //压缩包里面的文件扩展名
aa:='winrar e o+ '+file_name+' '+dbpath+''; //解压,覆盖,,
if not fileexists(file_name) then
begin
messagebox(handle,pchar(file_name+'文件不存在,无法进行解压缩操作!'),'提示信息',0);
exit;
end; if winexec(pchar(aa),sw_hide)<=31 then
begin
messagebox(handle,'解压缩操作失败!','提示信息',0);
exit;
end;
winrar 是收费软件,并不是所有电脑都有安装它的。
其实你可以调用 unrar.dll 来解压。
但是,很多免费的开源的解 zip 文件的三方组件,为什么不用呢?如果你懒得安装三方控件,用 SciZipFile 这个类就是很好的选择。它不用安装,直接调用就行。