system() without window

okibi okibi at ratedo.com
Wed Jul 11 11:05:39 PDT 2007


I tried your method for popen and i get "Symbol undefined" errors. I also tried this code:

extern (C) {
	typedef void FILE;
	FILE* popen(char* cmd, char* type);
	int pclose(FILE* stream);
}

and get the same errors.

Any ideas?

Regan Heath Wrote:

> 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