Jump to content

Check out our Community Blogs


Member Since 22 Dec 2016
Offline Last Active Dec 22 2016 03:42 AM

Posts I've Made

In Topic: Execute a Console Program and Capture Its Output

22 December 2016 - 03:06 AM

Full Source Codes of ExecAndCapture

Thanks for the function - I've tried it and found a problem with it: it hangs if there is zero-size output, because ReadFile() never returns. So I've changed it a bit to avoid this:

     // Read text returned by the console program in its StdOut channel
       if not PeekNamedPipe(vStdOutPipe.Output,vBuffer,cBufferSize,@vReadBytes,nil,nil) then break;
       if vReadBytes=0 then break;
       windows.ReadFile(vStdOutPipe.Output, vBuffer^, cBufferSize, vReadBytes, nil);
       if vReadBytes > 0 then

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download