Log in

View Full Version : Need some help with anonymous pipes...


dancho
8th November 2005, 18:39
Greetings everyone...
For now I'm using ShellExecute function in MCbatch to open/start
starttoencode.bat.
This batch file is started in console window,mencoder doing some
encoding and when is done console is closed.
And I would like to skip console appear at all with some help from pipes.
Now I know that we can create anonymous pipes and transfer data between console and some dialog or editbox or something...
And I was wondering if anyone could give me some info how it can be done,
which api to call,in what order etc...
Or some examples in C,masm,nasm...
Thx

Harlequin
9th November 2005, 00:51
On the platform sdk docs
ms-help://MS.PSDKXPSP2.1033/dllproc/base/creating_a_child_process_with_redirected_input_and_output.htm

Creating a Child Process with Redirected Input and Output

dancho
9th November 2005, 10:04
Ok,this is what I did found so far...
This is c/p from win32 p.r. with some steps for creating anonymous pipes:

1. Call the GetStdHandle function to get the current standard output handle; save the handle for later use.
2. Call the CreatePipe function to create an anonymous pipe. This function returns handles to the read and write ends of the pipe.
3. Call the SetStdHandle function to set its standard output to be the write handle of the pipe.
4. Call the CreateProcess function to create the child process. The child process inherits the inheritable handles of the parent process. It also inherits the values of the standard handles of its parent process, which it can retrieve using the GetStdHandle function.
5. Call the CloseHandle function to close the parent's handle to the write end of the pipe. After the child process inherits this handle, the parent process no longer needs its copy of the handle.
6. Call the ReadFile function to read from the pipe. This operation enables the parent process to read the data written to standard output by the child process.

:scared:

Harlequin
9th November 2005, 19:59
I think the problem is that batch files on their own aren't executable, wich leaves the options of launching it as an argument to cmd.exe / command.com or disecting the batch file and including each seperate program call as a seperate pipe.