?
Hi leute ich suche nach einer Funktion der ich einen buffer übergeben kann, in dem buffer steht ein befehl z.b, dir, und die dann den befehl ausführt und ich das ergebnis wieder in einen buffer stehen habe
ich habe das so gelößt.
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
void Commandexe( char buf[] );
int main()
{
char buf[216];
memset(buf,32,216);
strcpy(buf,"dir");
Commandexe(buf);
}
#include <stdio.h>
#include <stdlib.h>
void Commandexe( char buf[] )
{
char psBuffer[128];
FILE *netuser;
/* Run 'net user' so that it writes its output to a pipe. Open this
* pipe with read text attribute so that we can read it
* like a text file.
*/
if( (netuser = _popen( buf ,"r")) == NULL )
exit( 1 );
/* Read pipe until end of file. End of file indicates that
* 'net user' closed its standard out (probably meaning it
* terminated).
*/
while( !feof( netuser ) )
{
if( fgets( psBuffer, 128, netuser ) != NULL )
printf("%s",psBuffer);
}
_pclose( netuser );
}
jedoch geht das nur mit ner windows consolen app, und net mit ner win32 app,
die ich brauche, gibts da ne funktion die das kann auch mit einer win32 app???
habe das gefunden
[url] http://msdn.microsoft.com/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp [/url]
jedoch finde ich das zu kompliziert (ich kappier es nicht ;=) )für so was biliges, gibts da nicht kurzen und effizentes ???
1000. dank