Win32 |
Author |
Message |
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Sun Apr 10, 2022 10:54 am Post subject: Processes |
|
|
msft - Creating a Child Process with Redirected Input and Output
"The example in this topic demonstrates how to create a child process using
the CreateProcess function from a console process. It also demonstrates a
technique for using anonymous pipes to redirect the child process's standard
input and output handles. Note that named pipes can also be used to redirect
process I/O." |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Mon Mar 20, 2023 8:32 pm Post subject: |
|
|
so - Execute command using Win32
Having standard input: Code: | STARTUPINFO si = {0};
si.cbSize = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
si.hStdOutput = hStdOutWr;
si.hStdError = hStdErrWr;
|
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Mon Mar 20, 2023 8:48 pm Post subject: |
|
|
so - Using ShellExecuteEx and capturing standard in/out/err
Use text editor and type dir > out.txt and save it with mybat.bat (*.bat, don't *.txt)
In your c/c++ program, type WinExec("mybat.bat", SW_HIDE); and run your application.
Open the out.txt you will see the name of folders and files in current directory. |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Mon Apr 03, 2023 9:04 am Post subject: |
|
|
betaarchive.com - HOWTO: Spawn Console Processes with Redirected Standard Handles
"This article describes how to redirect the input and output of a child process
that receives input from the standard input handle or sends output to the
standard output handle. The Win32 API enables applications to spawn a child
console process with redirected standard handles. This feature allows a parent
process to send and receive the input and output of the child process." |
|
Back to top |
|
|
|