Autor Beitrag
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mi 01.01.03 19:53 
Hi,
ich lese mit folgendem Code aus einem Handle:
ausblenden Quelltext
1:
if WaitForSingleObject(hOReadPipe,0)<>WAIT_TIMEOUT then ReadFile(hOReadPipe, Buffer[0], BUFSIZE, BytesRead, nil) else Application.ProcessMessages;					

Gibt es etwas zu lesen, so erhalte ich auch was ich brauche. Ist jedoch schon alles aus dem Handle ausgelesen, wird ReadFile trotzdem ausgeführt. Es wartet auf Inhalt, den es nicht kriegt. Und wartet - folglich liegt der Fehler in WaitForSingleObject... Aber wie kann ich das Ändern?

maxk

PS: Ich versuche eine Ausgabe von DOS-Abzufangen. Der Code des Beitrages kommt dabei nicht in Frage, da ich die Ausgabe brauche, während das Programm noch läuft - und nicht erst da nach.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mi 01.01.03 20:39 
Wie kommst du darauf, das WaitForSingleObject auch für Pipes funktioniert?
Aus dem PSDK:
Zitat:
Change notification
Console input
Event
Job
Mutex
Process
Semaphore
Thread
Waitable timer


Eine Lösung habe ich natürlich parat, da ich dieses Problem auch schon hatte.
ausblenden Quelltext
1:
2:
3:
4:
function TPipe.BytesInPipe(ReadPipe: THande): Cardinal;
begin
  if not PeekNamedPipe(FReadPipe, nil, 0, nil, @Result, nil) then Result := 0;
end;

_________________
Ist Zeit wirklich Geld?
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Do 02.01.03 22:20 
:) Danke, werd's mal ausprobieren!

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.