Почему не читает проценты? Также не считывает данные с razor.
Для FreeArc все работает, но это и не нужно.
	
	
		
			
	
	
	
		
		
	
Содержимое 1.txt
	
	
		
			
	
Среда разработки - Delphi XE3.
Что-то не пойму как решить
				
			Для FreeArc все работает, но это и не нужно.
		Код:
	
	program Project4;
uses
  Windows;
{$R *.res}
function ExtractFilePath(Files: String): String; var N: Integer; S:String;
begin
  S:= Files;
if S[Length(S)]='\' then
  Delete(S,Length(S),1);
  N:= Pos('\',S);
while N > 0 do begin
  S:= Copy(S,N+1,Length(S)-N);
  N:= Pos('\',S);
end;
  Result:= Copy(Files, 0, Length(Files)-Length(S));
end;
function StrPas(const Str: PAnsiChar): string;
begin
  Result := string(Str);
end;
type
  TSysCharSet = set of AnsiChar;
function CharInSet(C: WideChar; const CharSet: TSysCharSet): Boolean;
begin
  Result := (C < #$0100) and (AnsiChar(C) in CharSet);
end;
type
  ThreadParams = record
    hReadPipe : THandle;
    s : String;
  end;
  PThreadParams = ^ThreadParams;
function ThreadRead(Info : PThreadParams):Dword; stdcall;
var
  Buffer :  array [0..$FFFF] of AnsiChar;
  nb: DWord;
begin
  Result := 0;
  while ReadFile( Info.hReadPipe,
                  buffer,
                  SizeOf(buffer),
                  nb,
                  nil) do
  begin
    Buffer[nb] := #0;
  if nb = 0 then
    Break;
    Info.s := StrPas(buffer);
end;
end;
procedure ISExtract(const FileName, CmdParams: string);
var
  hReadPipe,
  hWritePipe: THandle;
  saPipe: TSecurityAttributes;
  StartInfo: TStartupInfo;
  ProcInfo: TProcessInformation;
  Params : ThreadParams;
  ReaderID, dRunning : Dword;
  ReaderHandle : THandle;
  Line, Result, CmdLine: String;
  f1:textfile;
begin
  CmdLine := '"' + FileName + '" ' + CmdParams;
  Result := '';
  ReaderHandle := 0;
  AssignFile(f1, ExtractFilePath(ParamStr(0))+'1.txt');
  Rewrite(f1);
  saPipe.bInheritHandle := True;
  saPipe.lpSecurityDescriptor := nil;
  saPipe.nLength := SizeOf(saPipe);
  if not CreatePipe(hReadPipe,hWritePipe, @saPipe,0) then
   Messagebox(0, 'Error!','', MB_ICONERROR);
  ZeroMemory(@StartInfo, SizeOf(StartInfo));
  StartInfo.cb := SizeOf(StartInfo);
  StartInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
  StartInfo.wShowWindow := SW_SHOW;
  StartInfo.hStdInput := hWritePipe;
  StartInfo.hStdOutput := hWritePipe;
  StartInfo.hStdError:= hWritePipe;
  try
  Params.hReadPipe := hReadPipe;
  ReaderHandle := CreateThread( nil,
                                0,
                                @ThreadRead,
                                @Params,
                                0,
                                ReaderId);
  if ReaderHandle = 0 then
   Messagebox(0, 'Error!','', MB_ICONERROR);
  if CreateProcess(nil,
                   PChar(cmdline),
                   nil,
                   nil,
                   True,
                   NORMAL_PRIORITY_CLASS,
                   nil,
                   nil,
                   StartInfo,
                   ProcInfo) then
    begin
      CloseHandle(ProcInfo.hThread);
      CloseHandle(hWritePipe);
    end
  else
   Messagebox(0, 'Error!','', MB_ICONERROR);
    repeat
      dRunning := WaitForSingleObject(ProcInfo.hProcess, 500);
      Result := Params.s;
      Messagebox(0, PChar(Result),'', MB_ICONINFORMATION);
      Line:= Result;
//      Line:= Copy(Line, Pos('%', Line)-6, 6);
//      for i:=length(Line) downto 1 do
//      if not CharInSet(Line[i], ['0'..'9','.']) then
//      Delete(Line, i, 1);
      Writeln(f1, Line);
    until (dRunning <> WAIT_TIMEOUT);
  if WaitForSingleObject(ReaderHandle, infinite) = WAIT_TIMEOUT then
     begin
       TerminateThread(ReaderHandle,0);
       TerminateProcess(ProcInfo.hProcess, 1);
     end;
  finally
    if ReaderHandle > 0 then
       CloseHandle(ReaderHandle);
    if ProcInfo.hProcess > 0 then
       CloseHandle(ProcInfo.hProcess);
    if hReadPipe > 0 then
       CloseHandle(hReadPipe);
       CloseFile(f1);
  end;
end;
begin
  ISExtract(ExtractFilePath(ParamStr(0))+'7z.exe', 'x -y data.pa');
//  ISExtract(ExtractFilePath(ParamStr(0))+'arc.exe', 'x -o+  -w.\ -dp_TEST data.arc');
end.7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
Scanning the drive for archives:
1 file, 429933320 bytes (411 MiB)
Extracting archive: data.pa
Everything is Ok
Size: 429933189
Compressed: 429933320
		Scanning the drive for archives:
1 file, 429933320 bytes (411 MiB)
Extracting archive: data.pa
Everything is Ok
Size: 429933189
Compressed: 429933320
Что-то не пойму как решить

			
				Последнее редактирование: 
			
		
	
								
								
									
	
								
							
							 
	 
 
		 )
) 
			