ProcessSetStdInFile Function

Action

Sets a standard input file before starting a process.

Setting an input file is sometimes necessary (undocumented Windows requirement) when redirecting output, for example xcopy.

Include file

kernel.bdh

Syntax

ProcessSetStdInFile(
      in hProcess       : number,
      in sStdInFileName : string ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hProcess The handle which identifies the process. The handle is returned by ProcessInitialize.
sStdInFileName Name of the input file.
Note: ProcessSetStdInFile only works if the process is initialized with the flags PROCESS_PIPED or PROCESS_ATTACHED, and must be called before ProcessStart and after ProcessInitialize.

Example

transaction TmyTrans1
  var
    iProcess : number;
    iStatus  : number;
  begin
    iProcess := ProcessInitialize("cmd",
      PROCESS_ATTACHED,
      "/C xcopy \\bin\\debug \\temp /y",
      "T:\\bin\\release",
      "T:\\temp\\xcopyout.log",
      "T:\\temp\\xcopyerr.log");
    ProcessSetStdInFile(iProcess,"T:\\temp\\xcopyin.log");
    ProcessStart(iProcess);
    iStatus := PROCESS_STATE_EXECUTING;
    while (iStatus = PROCESS_STATE_EXECUTING) do
      wait 1.0;
      iStatus := ProcessGetState(iProcess);
    end;

    ProcessFree(iProcess);
  end TmyTrans1;