Please send me an E-Mail for further Questions!
Main Topics
Browse All TopicsHello all,
I will want to have a main application and be able to send different text to control one or more external console application. (say test1.exe) I am using createprocess to call this external program. Can someone show me the code by using writeconsole or writefile to make this work??
--- my code ---
int main(int argc, char* argv[])
{
HANDLE OH = CreateFile( "output.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
if(CreateProcess("C:\\mast
NULL, // Application arguments
0,
0,
TRUE,
CREATE_NEW_CONSOLE,
0,
0, // Working directory
&siStartupInfo,
&piProcessInfo) == FALSE)
return 0;
siStartupInfo.dwFlags= STARTF_USESTDHANDLES ;
siStartupInfo.hStdInput=OH
//trying to write something simple to the other console
char buf[11];
strcpy(buf, "hello");
DWORD num;
int succ;
WriteFile(OH, buf, strlen(buf), NULL, NULL);
------------------
P.S. I notice that I cannot hv both NULL as the last two arguments in writefile function but I hv no idea what to put there... )
thx in advance!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Rather than using files, the correct way to do what you want to do, is to use pipes. See :
http://support.microsoft.c
for more details and a good sample.
ChristopH1987, you should (re)read this
http://www.experts-exchang
Please, don't go any further in that direction...
Check out http://support.microsoft.c
_nn_ : thanks for the page, I've actually read the page b4 :) but thanks anyway
the thing that I don't understand is that :rather than receiving inputs in the main console and pipe them straight to the child program, I will want to hv somehting like..
depending on the input : then send different msgs to my child,
say if input to main is 1
then i will want to send a to child
if input is 2
i will want to send aaa to child
how can I do that??
> rather than receiving inputs in the main console and pipe them straight to the child program, I will want to hv somehting like..
Well, that's basic programming. If you want another behavior, change the code. In pseudo code, the sample has
get x
send x
Based upon your requirements, you need to write something like :
get x
swtch x
case 1: send this
case 2: send that
etc.
The code you need to modify is in GetAndSendInputThread()
Business Accounts
Answer for Membership
by: ChristopH1987Posted on 2003-08-10 at 06:42:08ID: 9116982
HI!
I think you should use named pipes or local RPC for this!