Link to home
Start Free TrialLog in
Avatar of szafran
szafran

asked on

ShellExecute

Hi

I need need to run WinRAR with parameters using shellexecute (maybe something else, but this is the only one that i know of), it must be hidden, and the delphi app must wait for it to finish, it would be best to get the progress from it (job progress not file progress - if it's possible, if not then nevermind ;)

Greets
ASKER CERTIFIED SOLUTION
Avatar of Jase-Coder
Jase-Coder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of szafran
szafran

ASKER

and... how exactly do i use it ??
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of szafran

ASKER

i've allready managed to write me a code for winrar, it's something like this:

  ExecuteFile:='C:\Program Files\WinRAR\WinRAR.exe';
  ParamString := '-cpSpisFilmow';
  FillChar(SEInfo, SizeOf(SEInfo), 0);
  SEInfo.cbSize := SizeOf(TShellExecuteInfo);
    with SEInfo do begin
      fMask := SEE_MASK_NOCLOSEPROCESS;
      Wnd := Application.Handle;
      lpFile := PChar(ExecuteFile);
      lpParameters := PChar(ParamString);
      nShow := SW_HIDE;
    end;
    if ShellExecuteEx(@SEInfo) then
      begin
          repeat
            Application.ProcessMessages;
            GetExitCodeProcess(SEInfo.hProcess, ExitCode);
          until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
        Label1.Caption := 'Kompresja zako&#324;czona';
        Form1.Activate;
        Form1.Refresh;
        Sleep(500);
      end
    else
      begin
        Label1.Caption := 'B&#322;&#261;d podczas uruchamiania WinRARa !';
        SpeedButton1.Enabled := False;
        Form1.Refresh;
        Sleep(10000);
        Label1.Caption := 'Zamykam program...';
        Form1.Refresh;
        Sleep(3000);
        Application.Terminate;
        Exit;
      end;

now... can anyone tell me for 100% that i can't get the progress from winrar ??
Use JvCreateProcess in JEDI component library!
hi
if your goal is to make your delphi app compress a file why do not use winzip you can search for a component named ziptv or file named xceedzip.dll if you accepted this tell me how can I send you xceedzip.dll to use it from delphi without nedding shellexecute
Avatar of szafran

ASKER

@LukaSDos

what will achieve by using it ??

@tammoz

zips compression ratio is way worse than rar's ... so it's discarding the use of it on the start (other thing is that i have allready moded the sfx module of winrar for my needs)
WinRar should have a parameter to send progress output to a file, and if it doesn't, you can force it by using something like: ParamString := '-cpSpisFilmow > C:\temp\rarlog.txt';

Then, in your waiting code, check this file every seconds or so (try to open it "read only") and look at the last line, to see the percentages you want to display.

May be you will need to add a -verbose command to get more info in the output, but the basic idea reamins the same.
Avatar of szafran

ASKER

that is impossible because rar showa an error that the file is in use by another app (doesn't matter if the file was created earlier or not)
Exactly what is impossible (you don't say witch of the posibilities you have tested)? With file rar says is in use?
Avatar of szafran

ASKER

i was talking about the log file
no matter what rar always shows that it is in use by another app and it can't write to it
OK, try this: Create an empty file for the log, and when calling the rar command, add ">> file.log". The difference is that double > means "add output to this existing file" instead of "create/clear the file and put the log in". Not sure it will do the work, I should install winrar and try my self maybe, but make a quick try anmd let me know.
Avatar of szafran

ASKER

doesn't work either (same error)