ProcessSetOutputBuffer Function

Action

Saves the output of the process to a string buffer.

重要: This function must be called before the ProcessStart function and after the ProcessInitialize function.
注: Does only work if the process is started PIPED. For this the parameter nFlag of the function ProcessInitialize must be set to PROCESS_PIPED.

Include file

Kernel.bdh

Syntax

ProcessSetOutputBuffer( in hProc          :number,
                        in sBuffer        :string,
                        in nBufferLen     :number optional,
                        in sLineSeparator :stringoptional ): boolean;

Return value

  • true if successful.

  • false in case of an error. The GetLastError function may be used to retrieve the system error code.

Parameter Description
hProc The handle that identifies the process. It is returned by the ProcessInitialize function.
sBuffer Pointer to the buffer used for writing the process output.
sBufferLen Maximum size of the string buffer (optional).
sLineSeparator The line separator which is placed between every line in the string buffer. If it is null, nothing is placed between the particular lines (optional).

Example

dcltrans
  transaction TMain
  var
    hProcessId : number;
    sBuffer : string(4096);
    sErrorBuffer : string(2048);
  begin
    // Create process and start it up...
    hProcessId := ProcessInitialize("application1.exe", PROCESS_PIPED,
                                      "", "c:\\temp\\", "c:\\temp\\out.txt");
    ProcessSetEnv(hProcessId, "temp", "c:\\temp\\");
    ProcessSetOutputBuffer(hProcessId, sBuffer, STRING_COMPLETE, ";");
    ProcessSetErrorBuffer(hProcessId, sErrorBuffer);
    ProcessStart(hProcessId);
    Print("StdOut: " + sBuffer);
    Print("ErrorOut: " + sErrorBuffer);

    ProcessFree(hProcessID);
  end TMain;