system() without window

Regan Heath regan at netmail.co.nz
Wed Jul 11 10:21:59 PDT 2007


okibi wrote:
> Is there documentation somewhere on how these work? Also, will they work on both Windows and Linux?
> 
> Thanks!
> 
> Regan Heath Wrote:
> 
>> okibi wrote:
>>> Hey,
>>>
>>> Is it possible to run a command with the system() function without having the program open up a command prompt until it finishes?
>>>
>>> Thanks!
>> I doubt it.. but you can call CreateProcess and prevent the window 
>> appearing.  Also there is popen which may prevent it.  Both are more 
>> complicated than system but offer more flexibility too.
>>
>> Regan
> 

Popen;
http://www.opengroup.org/pubs/online/7908799/xsh/popen.html

You will need to do something like:

extern(C) FILE *popen(const char *command, const char *mode);

in your D source file before you can call it.  See dm\include\stdio.h 
for the function declaration.  Any function you can find in the dm 
include directories can be called like this.

I wrote a ProcessStream using CreateProcess etc which worked on both 
windows and linux (although there may have been a few bugs to deal with):

http://www.digitalmars.com/d/archives/digitalmars/D/learn/internal_error_toObjFile_7911.html

You can find stuff like this by searching the archives here:
http://www.digitalmars.com/d/archives/digitalmars/D/index.html
http://www.digitalmars.com/d/archives/digitalmars/D/learn/index.html
..etc..

Regan


More information about the Digitalmars-d-learn mailing list