Prevent console open on popen?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • philipwayne
    New Member
    • Mar 2010
    • 50

    Prevent console open on popen?

    Is there a way I can prevent the console from opening when I use popen or would I have to do that in the program I am opening?
  • pavunkumar
    New Member
    • Feb 2010
    • 4

    #2
    For which purpose you want to do this things, if I know I can tell the better solution for you

    Comment

    • philipwayne
      New Member
      • Mar 2010
      • 50

      #3
      A PHP viewer type deal. Not really to sure how to explain it but basically:
      We type PHP source on one side of the application and hit a button then the other side displays the output.

      If you need/want to see the program its here ( do note PHP must be installed and on the path ) compiled on windows.



      When I execute the code the PHP console opens and closes.

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        What command line do you use to execute the code?
        What function call do you use to run that command?
        Does this have to be portable or is it Windows only?

        Comment

        • philipwayne
          New Member
          • Mar 2010
          • 50

          #5
          Command line is "php FILE".
          Function is _popen/fputs not sure which one you meant.
          Windows is fine I'm sure I can find the linux way.

          Code:
          void HPreview::updatePage( )
          {
          	FILE *fp1 = fopen( "source", "w" );
          	fputs( this->input->toPlainText( ).toStdString( ).c_str( ), fp1 );
          	fclose( fp1 );
          	
          	char buffer[1024];
          	QString output( "" );
          	long length;
          	
          	FILE *fp = _popen( "php source", "r" );
          	
          	while( fgets( buffer, sizeof( buffer ), fp ) != NULL )
          	{
          		output.append( buffer );
          	}
          	
          	fclose( fp );
          	
          	this->output->setHtml( output );
          }
          I doubt it matters but I'm using the Qt framework.

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            You may have to do some experimentation but I think you could achieve what you want using CreateProcess. But you would have to create your own pipe for stdin/stdout first.

            Comment

            • philipwayne
              New Member
              • Mar 2010
              • 50

              #7
              Okay, thank you I'll look in to that.

              Comment

              Working...