Показать сообщение отдельно
  #21  
Старый 10.12.2015, 19:37
VKoonts VKoonts вне форума
Прохожий
 
Регистрация: 06.12.2015
Сообщения: 13
Версия Delphi: XE8 v.22xx
Репутация: 10
По умолчанию

Нашел другой способ получить необходимые данные:

Код:
procedure RunDosInMemo( DosApp, dd:String;AMemo:TMemo);
 const
    ReadBuffer = 2400;
 var
  Security            : TSecurityAttributes;
  ReadPipe,WritePipe  : THandle;
  start               : TStartUpInfo;
  ProcessInfo         : TProcessInformation;
  Buffer              : PAnsichar;
  BytesRead           : DWord;
  Apprunning          : DWord;
  Fil                : string;
 begin
  With Security do begin
   nlength              := SizeOf(TSecurityAttributes);
   binherithandle       := true;
   lpsecuritydescriptor := nil;
  end;
  if Createpipe (ReadPipe, WritePipe,
                 @Security, 0) then begin
   Buffer  := AllocMem(ReadBuffer + 1);
   FillChar(Start,Sizeof(Start),#0);
   start.cb          := SizeOf(start);
   start.hStdOutput  := WritePipe;
   start.hStdInput   := ReadPipe;
   start.dwFlags     := STARTF_USESTDHANDLES +
                        STARTF_USESHOWWINDOW;
   start.wShowWindow := SW_HIDE;
      Fil := DosApp;
      Fil := Fil + dd;
   if CreateProcess(nil,
          PChar(Fil),
          @Security,
          @Security,
          true,
          NORMAL_PRIORITY_CLASS,
          nil,
          nil,
          start,
          ProcessInfo)
   then
   begin
    repeat
     Apprunning := WaitForSingleObject
                  (ProcessInfo.hProcess,100);

    until (Apprunning <> WAIT_TIMEOUT);
     Repeat
       BytesRead := 0;
       ReadFile(ReadPipe,Buffer[0],
               ReadBuffer,BytesRead,nil);
       Buffer[BytesRead]:= #0;
       AMemo.Text := AMemo.text + String(Buffer);
     until (BytesRead < ReadBuffer);
  end;
  FreeMem(Buffer);
  CloseHandle(ProcessInfo.hProcess);
  CloseHandle(ProcessInfo.hThread);
  CloseHandle(ReadPipe);
  CloseHandle(WritePipe);
  end;
 end;

procedure TForm1.Button2Click(Sender: TObject);
var
onepart,twopart: string;

begin
  Memo1.Clear;
  onepart:= Copy(Edit1.Text,1,1);
  twopart:= Copy(Edit1.Text,2,Length(Edit1.Text)-1);
  RunDosInMemo(onepart,twopart,Memo1);
end;
Ответить с цитированием