Writefile API inside same procedure

two thoughts:

  1. have a look at this thread and use -11 for STD_OUTPUT_HANDLE

or

  1. consider using OddJob

https://www.capesoft.com/accessories/OddJobsp.htm

“Provides the ability to write data to a process’ StdIn, and read from the StdOut - allowing communication with command line processes such as servers, compilers, script interpreters (such as PHP, Python and so on), etc.”