Delphi中调用API函数Winexec执行WinRar命令行压缩工具执行压缩

function tform1.RarFile:Boolean;
var
  FileName,RarName,mystr:string;
begin
  Result:=False;
  mystr:=ExtractFilePath(Application.ExeName)+'WinRar\WinRar.exe -INUL';
  FileName:=ExtractFilePath(Application.ExeName)+'Excel\*.*';
  RarName:=ExtractFilePath(Application.ExeName)+'RarFile\WeeklyReport'+''+formatdatetime('yyyy-mm-dd',Now)+'.rar';
  mystr:=mystr+' a -EP1 '+RarName+' '+FileName;
  if WinExec(PChar(mystr),SW_SHOW)>0 then
  begin
    Result:=True;
  end;
end;

昨日找到的Delphi中调用Winexec API函数执行WinRaR命令行压缩的方法,谨以此做个记录,以备以后忘记时使用。

posted @ 2013-12-23 09:49  vage_fang  阅读(643)  评论(0编辑  收藏  举报