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

function tform1.RarFile:Boolean;
var
  FileName,RarName,mystr:string;
begin
  Result:=False;
  mystr:=ExtractFilePath(Application.ExeName)+'WinRarWinRar.exe -INUL';
  FileName:=ExtractFilePath(Application.ExeName)+'Excel*.*';
  RarName:=ExtractFilePath(Application.ExeName)+'RarFileWeeklyReport'+''+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命令行压缩的方法,谨以此做个记录,以备以后忘记时使用。

原文地址:https://www.cnblogs.com/vage/p/3486920.html