• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

Redirect output to a file in VC++

I want to run a dos based programm with 2 considerations under VC++.
1. There is no popup screen (This is easy using SW_HIDE).
*2. Redirect the output of the program to a file.
The problem is that CreateProcess, ShellExecute can not redirect the output of the program to a File (or it does that I don't know). Can anyone suggest anything?
0
riyafath
Asked:
riyafath
1 Solution
 
emalagarCommented:
Hi riyafath :

Did you try to create .bat file that executes the program and performs the redirection, and then execute the .bat file instead from CreateProcess or ShellExecute.

0
 
nandenCommented:
Reassign a file pointer.

FILE *freopen( const char *path, const char *mode, FILE *stream );

FILE *_wfreopen( const wchar_t *path, const wchar_t *mode, FILE *stream );

for more information, see the freopen function is MSDN.
HTH,
0
 
vadikCommented:
There is topin in MSDN "Creating a Child Process with Redirected Input and Output". I did it half year ago... but this way having another problem... if your hide-process suddenly are waiting for input he is going to suspend of indefinite time. Sorry for my English.
0
 
vadikCommented:
There is topic in MSDN "Creating a Child Process with Redirected Input and Output". I did it half year ago... but this way having another problem... if your hide-process suddenly are waiting for input he is going to suspend of indefinite time. Sorry for my English.
0
 
CleanupPingCommented:
riyafath:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now