Einzelnen Beitrag anzeigen

Benutzerbild von Dalai
Dalai

Registriert seit: 9. Apr 2006
1.680 Beiträge
 
Delphi 5 Professional
 
#9

Re: CMD-Ausgabe von chkdsk, wget usw. ordentlich?

  Alt 2. Jun 2009, 00:15
Ich hoffe nochmals auf eure Hilfe .

Meine Änderung bzgl. Konvertierung in ANSI tut nicht so, wie ich das hoffte . In der Methode TDosThread.FExecute habe ich folgende Änderung vorgenommen (durch Kommentar markiert):
Delphi-Quellcode:
if (bread <> 0) then begin
  if (iBufSize < avail) then begin // If BufferSize too small then rezize
    iBufSize := avail;
    ReallocMem(pBuf, iBufSize);
  end;
  FillChar(pBuf^, iBufSize, #0); //empty the buffer
  ReadFile(read_stdout, pBuf^, iBufSize, bread, nil); //read the stdout pipe

  // --- Änderung
  if FConvert AND (bread > 0) then
      OemToChar(pBuf^, pBuf^);
  // --- Änderung

  Str := Last; //take the begin of the line (if exists)
  i := 0;
  while ((i < bread) and not (Terminated)) do begin
    case pBuf^[i] of
[...]
FConvert ist ein boolsches Attribut, was ich hinzugefügt habe.
Ein Rechner hat damit allerdings ein Problem und er beendet nicht nur das ausgeführte Konsolenprogramm sondern auch das Delphi-Prog sang- und klanglos. Meine Vermutung ist, dass die Variable pBuf^ nicht mit #0 abgeschlossen ist (in bestimmten Situationen) und OemToChar() deswegen ins Schlingern kommt.

Wie löse ich das mit möglichst wenig (Konvertierungs-)Aufwand?

MfG Dalai
  Mit Zitat antworten Zitat