Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using _popen() under windows mode applications

Status
Not open for further replies.

LinuxProgrammer

Programmer
Apr 4, 2002
3
US
I am trying to use the
Code:
_popen()
call to obtain data. For those that don't know _popen(), it's similar to fopen()'ing a file, but it opens a console application. (For example,
Code:
FILE *f = _popen("dir", "r");
would allow me to read the results of the dir command.)

In my application, if I include the linker flag "
Code:
/subsystem:console
" to make my application (the one using _popen()) a console app, _popen() works fine. However, my application itself is not a console application and I don't wish to have an empty dos window showing while it runs. To clear this window I link with "
Code:
/subsystem:windows
" instead. However, for a reason unknown to me, this breaks _popen() -- _popen() consistantly returns a NULL file pointer.

Any idea on how to either make _popen() work correctly in a windows subsystem, or hide the dos window in a console subsystem?

Thanks for any suggestions...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top